Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gamera_videos_no_ui
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liusq
gamera_videos_no_ui
Commits
4e92ddc7
Commit
4e92ddc7
authored
Oct 09, 2024
by
“liusq”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改一建配置Ip的问题
parent
e93312cf
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
7 deletions
+36
-7
NonConnectedCameraHandle.cpp
+10
-3
VidesData.h
+26
-4
No files found.
NonConnectedCameraHandle.cpp
View file @
4e92ddc7
...
@@ -49,6 +49,8 @@ bool NonConnectedCameraHandle::changeCameraIp(vides_data::localDevice &device){
...
@@ -49,6 +49,8 @@ bool NonConnectedCameraHandle::changeCameraIp(vides_data::localDevice &device){
if
(
nCount
<=
0
)
{
if
(
nCount
<=
0
)
{
qInfo
()
<<
QString
(
"SN(%1): 有线搜索不到设备"
).
arg
(
device
.
sSn
);
qInfo
()
<<
QString
(
"SN(%1): 有线搜索不到设备"
).
arg
(
device
.
sSn
);
//搜索不到设备也当不在,当不在同一网段
device
.
isMask
=
false
;
return
false
;
return
false
;
}
}
...
@@ -92,11 +94,18 @@ bool NonConnectedCameraHandle::changeCameraIp(vides_data::localDevice &device){
...
@@ -92,11 +94,18 @@ bool NonConnectedCameraHandle::changeCameraIp(vides_data::localDevice &device){
.
arg
(
pDevice
->
HostIP
.
c
[
1
])
.
arg
(
pDevice
->
HostIP
.
c
[
1
])
.
arg
(
pDevice
->
HostIP
.
c
[
2
])
.
arg
(
pDevice
->
HostIP
.
c
[
2
])
.
arg
(
pDevice
->
HostIP
.
c
[
3
]);
.
arg
(
pDevice
->
HostIP
.
c
[
3
]);
if
(
vides_data
::
isInSameSubnet
(
device
.
reachableIp
,
new_ip
,
subnetMask
)){
QString
new_Submask
=
QString
(
"%1.%2.%3.%4"
)
.
arg
(
pDevice
->
Submask
.
c
[
0
])
.
arg
(
pDevice
->
Submask
.
c
[
1
])
.
arg
(
pDevice
->
Submask
.
c
[
2
])
.
arg
(
pDevice
->
Submask
.
c
[
3
]);
if
(
vides_data
::
isInSameSubnet
(
device
.
reachableIp
,
new_ip
,
new_Submask
)){
device
.
isMask
=
true
;
device
.
isMask
=
true
;
}
else
{
}
else
{
device
.
isMask
=
false
;
device
.
isMask
=
false
;
}
}
device
.
nDevPort
=
pDevice
->
TCPPort
;
device
.
nDevPort
=
pDevice
->
TCPPort
;
XSDK_EncryptPassword
(
""
,
newEncryptPsw
,
512
);
XSDK_EncryptPassword
(
""
,
newEncryptPsw
,
512
);
...
@@ -200,8 +209,6 @@ void NonConnectedCameraHandle::printWifi(XSDK_HANDLE hDevice,XSDK_CFG::NetWork_W
...
@@ -200,8 +209,6 @@ void NonConnectedCameraHandle::printWifi(XSDK_HANDLE hDevice,XSDK_CFG::NetWork_W
int
NonConnectedCameraHandle
::
sdkDevLoginSyn
(
QString
sDevId
,
int
nDevPort
,
int
NonConnectedCameraHandle
::
sdkDevLoginSyn
(
QString
sDevId
,
int
nDevPort
,
QString
sUserName
,
QString
sPassword
,
int
nTimeout
)
{
QString
sUserName
,
QString
sPassword
,
int
nTimeout
)
{
SXSDKLoginParam
*
loginParam
=
new
SXSDKLoginParam
();
SXSDKLoginParam
*
loginParam
=
new
SXSDKLoginParam
();
ScopeSemaphoreExit
guard
([
&
loginParam
]()
{
ScopeSemaphoreExit
guard
([
&
loginParam
]()
{
Common
&
instace
=
Common
::
getInstance
();
Common
&
instace
=
Common
::
getInstance
();
MainWindow
::
sp_this
->
setIsResetting
(
false
);
MainWindow
::
sp_this
->
setIsResetting
(
false
);
...
...
VidesData.h
View file @
4e92ddc7
...
@@ -438,8 +438,6 @@ inline bool isInSameSubnet(const QString &ip1, const QString &ip2, const QString
...
@@ -438,8 +438,6 @@ inline bool isInSameSubnet(const QString &ip1, const QString &ip2, const QString
// 比较结果
// 比较结果
return
result1
==
result2
;
return
result1
==
result2
;
}
}
// 获取本地 MAC 地址、子网掩码和网关IP
inline
bool
GetNetworkInfoByQNetworkInterface
(
QString
&
mac
,
QString
&
subnetMask
,
QString
&
gateway
)
{
inline
bool
GetNetworkInfoByQNetworkInterface
(
QString
&
mac
,
QString
&
subnetMask
,
QString
&
gateway
)
{
QList
<
QNetworkInterface
>
interfaces
=
QNetworkInterface
::
allInterfaces
();
QList
<
QNetworkInterface
>
interfaces
=
QNetworkInterface
::
allInterfaces
();
foreach
(
QNetworkInterface
interface
,
interfaces
)
{
foreach
(
QNetworkInterface
interface
,
interfaces
)
{
...
@@ -452,13 +450,37 @@ inline bool GetNetworkInfoByQNetworkInterface(QString &mac, QString &subnetMask,
...
@@ -452,13 +450,37 @@ inline bool GetNetworkInfoByQNetworkInterface(QString &mac, QString &subnetMask,
foreach
(
QNetworkAddressEntry
entry
,
addressEntries
)
{
foreach
(
QNetworkAddressEntry
entry
,
addressEntries
)
{
if
(
entry
.
ip
().
protocol
()
==
QAbstractSocket
::
IPv4Protocol
)
{
if
(
entry
.
ip
().
protocol
()
==
QAbstractSocket
::
IPv4Protocol
)
{
subnetMask
=
entry
.
netmask
().
toString
();
subnetMask
=
entry
.
netmask
().
toString
();
gateway
=
entry
.
broadcast
().
toString
();
// 这里假设网关是广播地址
// 获取网关地址
QProcess
process
;
process
.
start
(
"ip"
,
QStringList
()
<<
"route"
);
if
(
!
process
.
waitForStarted
())
{
qInfo
()
<<
"Failed to start 'ip route' process."
;
continue
;
}
if
(
!
process
.
waitForFinished
())
{
process
.
kill
();
qInfo
()
<<
"Process 'ip route' timed out."
;
continue
;
}
QString
output
=
process
.
readAllStandardOutput
();
QStringList
lines
=
output
.
split
(
'\n'
);
foreach
(
QString
line
,
lines
)
{
if
(
line
.
startsWith
(
"default via"
))
{
QStringList
parts
=
line
.
split
(
QRegExp
(
"
\\
s+"
));
if
(
parts
.
size
()
>=
3
)
{
gateway
=
parts
[
2
];
return
true
;
return
true
;
}
}
}
}
}
}
}
}
return
false
;
// Return false if no suitable interface is found
}
}
}
return
false
;
// Return false if no suitable interface is found or gateway not found
}
}
inline
bool
pingAddress
(
const
QString
&
address
)
{
inline
bool
pingAddress
(
const
QString
&
address
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment