Skip to content

Alarm Module

This version of the alarm for the "defensive" alarm mode: refers to the SDK actively connected to the device, and initiate the alarm upload command, equipment alarm immediately sent to the SDK

Interface Overview

interface Name Functional Description
NET_SDK_SetupAlarmChan Configure Alarms
NET_SDK_SetDVRMessageCallBack DVR Alarm or Status Callback
NET_SDK_CloseAlarmChan Close the alarm

Process Description

---
title: Alarm Module Flow
---
flowchart TD
line1(Device SDK initialization<br><strong>NET_SDK_Init</strong>)
line2(User registration device<br><strong>NET_SDK_Login</strong> or<br><strong>NET_SDK_LoginEx</strong>)
line3(Configure alarm conditions and processing methods)
line4(Alarm or status callback<br><strong>NET_SDK_SetDVRMessageCallBack</strong>)
line5(Set alarm<br><strong>NET_SDK_SetupAlarmChan</strong>)
line6(Close alarm<br><strong>NET_SDK_CloseAlarmChan</strong>)
line7("Deregister device<br><strong>NET_SDK_Logout</strong>")
line8("Release SDK resources<br><strong>NET_SDK_Cleanup</strong>")
line1 --> line2 --> line3 --> line4 -->line5 -->line6 -->line7 -->line8

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

using namespace std;

void SubscribCallBack1(LONG lUserID, DWORD dwCommand, char *pBuf, DWORD dwBufLen, void *pUser)
{
    cout << "recive command: " << dwCommand << endl;
    // NET_SDK_SMART_EVENT_TYPE
    // According to different commands, do different processing
}

void DeviceAlarmProcess()
{
    // device info
    CString username = "admin";
    CString password = "123456";
    CString device_ip = "10.80.1.138";
    DWORD device_port = 9008;
    // 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;
    }

    // Setup alarm
    LONG handle = NET_SDK_SetupAlarmChan(userid);

    if (handle > 0)
    {
        cout << "Setup alarm handle: " << handle << endl;
    }
    else
    {
        DWORD error_code = NET_SDK_GetLastError();
        cout << "Setup alarm fail: " << error_code << endl;
    }

    NET_SDK_SetSubscribCallBack(SubscribCallBack1, NULL);
    // wait for alarm
    Sleep(100000);
    // Close alarm
    NET_SDK_CloseAlarmChan(handle);
    // logout
    NET_SDK_Logout(userid);
    NET_SDK_Cleanup();
}

Relevant Instructions

The orange colored box is a necessary condition for uploading alarm information, mainly completing the configuration of related alarm conditions and processing methods, the interfaces for parameter configuration are NET_SDK_GetDVRConfig and NET_SDK_SetDVRConfig, and the configuration structure for semaphore alarm is NET_SDK_ALARMINFO .

If these parameters have been configured, the next step is to set the arming NET_SDK_SetupAlarmChan, and then call the alarm callback function NET_SDK_SetDVRMessageCallBack

After the entire alarm upload process is completed, it is also necessary to call the defence interface and other operations.

Error Code