跳转至

参数配置

可以修改设备时间,设备网络设置等。

接口概览

接口名称 功能描述
NET_SDK_ChangTime 修改设备系统时间
NET_SDK_ModifyDeviceNetInfo 根据 MAC 地址匹配,修改设备网络配置
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_ChangeTime</strong>")
    D("修改设备网络配置<br><strong>NET_SDK_ModifyDeviceNetInfo</strong>")
    E(注销设备<br><strong>NET_SDK_Logout</strong>)
    F(释放SDK资源<br><strong>NET_SDK_Cleanup</strong>)

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

示例代码

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

void DemoUniversal::ChangeTime()
{
    // 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;
    }

    // set device time
    time_t now = time(nullptr);
    CTime current_time(now);
    bool isOk = NET_SDK_ChangTime(userid, current_time.GetTime());

    if (isOk)
    {
        cout << "Time setting successful: " << isOk << endl;
    }
    else
    {
        cout << "Time setting failed: " << isOk << endl;
    }

    // logout
    NET_SDK_Logout(userid);
    NET_SDK_Cleanup();
}
 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
#include <string>
#include <iostream>
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>

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

    // set device info
    NET_SDK_DEVICE_IP_INFO pDeviceIPInfo;
    memset(&pDeviceIPInfo, 0, sizeof(NET_SDK_DEVICE_IP_INFO));
    strcpy_s(pDeviceIPInfo.szMac, mBase->convertMacAddr(device_info.deviceMAC)); // Current MAC address of the device
    strcpy_s(pDeviceIPInfo.szIpAddr, "10.80.1.178");
    strcpy_s(pDeviceIPInfo.szMark, "255.255.255.0");
    strcpy_s(pDeviceIPInfo.szGateway, "10.80.1.1");
    strcpy_s(pDeviceIPInfo.szDdns1, "223.6.6.6");
    strcpy_s(pDeviceIPInfo.szDdns2, "8.8.8.8");
    strcpy_s(pDeviceIPInfo.szPassword, "123456");
    pDeviceIPInfo.ucIPMode = 0;
    bool isOk = NET_SDK_ModifyDeviceNetInfo(&pDeviceIPInfo);

    if (isOk)
    {
        cout << "Device information setting successful: " << isOk << endl;
    }
    else
    {
        cout << "Device information setting failed: " << isOk << endl;
    }

    // logout
    NET_SDK_Logout(userid);
    NET_SDK_Cleanup();
}
错误码