Remote Device Maintenance Remote device maintenance module includes functions such as getting device working status, remote upgrade, log lookup, restoring device default parameters and importing, exporting profile, etc.
Interface Overview Process Description ---
title: Remote Device Maintenance
---
flowchart TD
A(Device SDK initialization <br><strong>NET_SDK_Init</strong>)
B(User registers device <br><strong>NET_SDK_Login</strong> or <br><strong>NET_SDK_LoginEx</strong>)
C("Get device working status <br>...")
D("Device remote upgrade <br><strong>NET_SDK_Upgrade</strong>")
E("Device log search <br><strong>NET_SDK_FindDVRLog</strong>")
F("Restore device default configuration <br><strong>NET_SDK_RestoreConfig</strong>")
G("Import configuration file <br><strong>NET_SDK_GetConfigFile</strong>")
H("Export configuration file <br><strong>NET_SDK_SetConfigFile</strong>")
style C fill:#e7b13387
Y(Log out device <br><strong>NET_SDK_Logout</strong>)
Z(Release SDK resources <br><strong>NET_SDK_Cleanup</strong>)
A --> B
Y --> Z
B ---> C ---> Y
B ---> D ---> Y
B ---> E ---> Y
B ---> F ---> Y
B ---> G ---> Y
B ---> H ---> Y Get the working status of the device: you can get the current hard disk status, channel status, alarm input and output port status, local display status and voice channel status, etc. The dotted box indicates that this function is temporarily reserved in this version. Remote upgrade: Upgrade the device and get the current progress and status of the upgrade. Log Finder: You can search the log information of the current device, including alarms, exceptions, operations and logs with S.M.A.R.T information. Restore device default parameters: Calling interface NET_SDK_RestoreConfig restores all parameters of the device to their default values. Import and Export Configuration Files: Export and save all the current configuration information of the device or import the specified configuration information to the device. Sample Code Remote Upgrade Log Lookup Restore Device Default Parameters Export Device File Import Device File
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99 #include <iostream>
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>
using namespace std;
void RemoteUpgrade ()
{
// device info
CString username = "admin" ;
CString password = "123456" ;
CString device_ip = "10.80.1.177" ;
DWORD device_port = 6036 ;
// init sdk
NET_SDK_Init();
NET_SDK_SetConnectTime(6000 , 1 );
NET_SDK_SetReconnect();
// 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 ;
}
// nvr upgrade
// NET_SDK_Upgrade tar package
// NET_SDK_UpgradeEx firmware package
CString filename = "D: \\ N0N_UI1A_230522_148_59579.release.fls" ; // firmware package path
long lUpgradeHandle = NET_SDK_Upgrade(userid, filename.GetBuffer(0 ));
if (lUpgradeHandle != -1 )
{
cout << "Firmware package uploaded successfully." << endl;
// check upgrade status
while (true )
{
int nState = NET_SDK_GetUpgradeState(lUpgradeHandle);
if (nState == 3 )
{
cout << "Upgrade fail 3" << endl;
break ;
}
else if (nState == 4 )
{
cout << "Upgrade fail 4" << endl;
break ;
}
else if (nState == 5 )
{
cout << "Upgrade fail 5" << endl;
break ;
}
int nPos = NET_SDK_GetUpgradeProgress(lUpgradeHandle);
if (nPos >= 100 )
{
cout << "Upgrade successful." << endl;
NET_SDK_CloseUpgradeHandle(lUpgradeHandle);
break ;
}
cout << "Upgrading: " << nState << " " << nPos << "%" << endl;
Sleep(500 );
}
}
else
{
cout << "firmware package upload failed: " << lUpgradeHandle << endl;
DWORD LastError = NET_SDK_GetLastError();
if (LastError == NET_SDK_BUSY)
{
cout << "device busy!" << endl;
}
else if (LastError == NET_SDK_FILE_NOT_MATCH_PRODUCT)
{
cout << "same version!" << endl;
}
else
{
cout << "Faild :" << LastError << 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84 #include <iostream>
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>
using namespace std;
CTime parseStrTimeToCTime1 (string_view intime)
{
tm tm = {};
istringstream ss(intime.data());
ss >> get_time(& tm, "%Y-%m-%d %H:%M:%S" );
time_t tt = mktime(& tm);
CTime ctime(tt);
return ctime;
}
void FindDVRLog ()
{
// 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 ;
}
// Search time period for alarm logs.
CTime startTime = parseStrTimeToCTime1("2023-04-13 00:00:00" );
CTime endTime = parseStrTimeToCTime1("2023-04-13 23:59:59" );
DD_TIME start = {startTime.GetSecond(), startTime.GetMinute(), startTime.GetHour(), 0 , startTime.GetDay(), startTime.GetMonth() - 1 , startTime.GetYear() - 1900 };
DD_TIME end = {endTime.GetSecond(), endTime.GetMinute(), endTime.GetHour(), 0 , endTime.GetDay(), endTime.GetMonth() - 1 , endTime.GetYear() - 1900 };
// Start searching for alarm logs LOG_ALARM_ALL
int loghandle = NET_SDK_FindDVRLog(userid, LOG_ALARM_ALL, & start, & end);
// Search for specific content
NET_SDK_LOG log;
long result = 0 ;
while (true )
{
result = NET_SDK_FindNextLog(loghandle, & log);
if (result == NET_SDK_NOMOREFILE)
{
break ;
}
// You can process only the required minor types
// if (log.dwMinorType == LOG_ALARM_INTELLIGENT) {
// cout << log.sContent << endl;
//}
cout << "Log main type: " << log.dwMajorType << " Log sub type: " << log.dwMinorType << " Log content: " << log.sContent << endl;
}
// Close the search
NET_SDK_FindLogClose(loghandle);
// 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 #include <iostream>
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>
void RestoreConfig ()
{
// 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 ;
}
// Restore to factory settings
bool isOk = NET_SDK_RestoreConfig(userid);
if (isOk)
{
cout << "Restore to factory settings successful" << endl;
}
else
{
cout << "Restore to factory settings failed" << 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 #include <iostream>
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>
void GetConfigFile ()
{
// 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 ;
}
// Export configuration file
CString fileName = "config.dat" ;
bool isOk = NET_SDK_GetConfigFile(userid, fileName.GetBuffer());
if (isOk)
{
cout << "Configuration file exported successfully" << endl;
}
else
{
cout << "Configuration file export failed" << 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 #include <iostream>
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>
void SetConfigFile ()
{
// 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 ;
}
// Import configuration file
CString fileName = "ConfigurationBackupFile.txt" ;
bool isOk = NET_SDK_SetConfigFile(userid, fileName.GetBuffer());
if (isOk)
{
cout << "Configuration file imported successfully" << endl;
}
else
{
cout << "Configuration file import failed" << endl;
}
// logout
NET_SDK_Logout(userid);
NET_SDK_Cleanup();
}
Relevant Instructions nothing