Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ademco_hb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
ademco_hb
Commits
19290bbb
Commit
19290bbb
authored
Aug 25, 2020
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Req Resp
parent
fa5fbacf
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
68 deletions
+68
-68
server_demo_libevent.cpp
examples/server_demo_libevent/server_demo_libevent.cpp
+11
-11
hb_detail.h
include/hb_detail.h
+57
-57
No files found.
examples/server_demo_libevent/server_demo_libevent.cpp
View file @
19290bbb
...
@@ -203,8 +203,8 @@ void handle_com_passthrough(ThreadContext* context, Client& client, evbuffer* ou
...
@@ -203,8 +203,8 @@ void handle_com_passthrough(ThreadContext* context, Client& client, evbuffer* ou
break
;
break
;
case
com
:
:
ResponseParser
::
ResponseType
::
A2_response
:
case
com
:
:
ResponseParser
::
ResponseType
::
A2_response
:
{
{
com
::
A2R
resp
;
memcpy
(
resp
.
data
,
xdata
.
data
(),
xdata
.
size
());
resp
.
len
=
xdata
.
size
()
&
0xFF
;
com
::
Resp_A2
resp
;
memcpy
(
resp
.
data
,
xdata
.
data
(),
xdata
.
size
());
resp
.
len
=
xdata
.
size
()
&
0xFF
;
com
::
A2R
::
ZoneAndProperties
zps
;
bool
hasMore
=
false
;
com
::
Resp_A2
::
ZoneAndProperties
zps
;
bool
hasMore
=
false
;
if
(
client
.
queryStage
==
QueryStage
::
QueryingZones
&&
resp
.
parse
(
zps
,
hasMore
))
{
if
(
client
.
queryStage
==
QueryStage
::
QueryingZones
&&
resp
.
parse
(
zps
,
hasMore
))
{
for
(
const
auto
&
zp
:
zps
)
{
for
(
const
auto
&
zp
:
zps
)
{
ZonePropertyAndLostConfig
zplc
;
ZonePropertyAndLostConfig
zplc
;
...
@@ -218,10 +218,10 @@ void handle_com_passthrough(ThreadContext* context, Client& client, evbuffer* ou
...
@@ -218,10 +218,10 @@ void handle_com_passthrough(ThreadContext* context, Client& client, evbuffer* ou
}
}
XDataPtr
xdata
;
XDataPtr
xdata
;
if
(
hasMore
)
{
// 继续索要剩余防区
if
(
hasMore
)
{
// 继续索要剩余防区
com
::
A2
req
;
com
::
Req_
A2
req
;
xdata
=
makeXData
((
const
char
*
)
req
.
data
,
req
.
len
);
xdata
=
makeXData
((
const
char
*
)
req
.
data
,
req
.
len
);
}
else
{
// 开始索要防区失联设置
}
else
{
// 开始索要防区失联设置
com
::
AC
req
;
com
::
Req_
AC
req
;
xdata
=
makeXData
((
const
char
*
)
req
.
data
,
req
.
len
);
xdata
=
makeXData
((
const
char
*
)
req
.
data
,
req
.
len
);
client
.
queryStage
=
QueryStage
::
QueryingLostConfig
;
client
.
queryStage
=
QueryStage
::
QueryingLostConfig
;
}
}
...
@@ -254,7 +254,7 @@ void handle_com_passthrough(ThreadContext* context, Client& client, evbuffer* ou
...
@@ -254,7 +254,7 @@ void handle_com_passthrough(ThreadContext* context, Client& client, evbuffer* ou
{
{
if
(
client
.
queryStage
==
QueryStage
::
QueryingTimer
)
{
if
(
client
.
queryStage
==
QueryStage
::
QueryingTimer
)
{
client
.
queryStage
=
QueryStage
::
None
;
client
.
queryStage
=
QueryStage
::
None
;
com
::
A6R
resp
;
memcpy
(
resp
.
data
,
xdata
.
data
(),
resp
.
len
);
com
::
Resp_A6
resp
;
memcpy
(
resp
.
data
,
xdata
.
data
(),
resp
.
len
);
client
.
timer
=
resp
.
getTimer
();
client
.
timer
=
resp
.
getTimer
();
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
if
(
com
::
isValidMachineTimer
(
client
.
timer
.
timer
[
i
]))
{
if
(
com
::
isValidMachineTimer
(
client
.
timer
.
timer
[
i
]))
{
...
@@ -286,7 +286,7 @@ void handle_com_passthrough(ThreadContext* context, Client& client, evbuffer* ou
...
@@ -286,7 +286,7 @@ void handle_com_passthrough(ThreadContext* context, Client& client, evbuffer* ou
break
;
break
;
case
com
:
:
ResponseParser
::
ResponseType
::
AD_response
:
case
com
:
:
ResponseParser
::
ResponseType
::
AD_response
:
{
{
com
::
ADR
resp
;
memcpy
(
resp
.
data
,
xdata
.
data
(),
xdata
.
size
());
resp
.
len
=
xdata
.
size
()
&
0xFF
;
com
::
Resp_AD
resp
;
memcpy
(
resp
.
data
,
xdata
.
data
(),
xdata
.
size
());
resp
.
len
=
xdata
.
size
()
&
0xFF
;
bool
hasMore
=
false
;
bool
hasMore
=
false
;
std
::
vector
<
size_t
>
zones
;
std
::
vector
<
size_t
>
zones
;
if
(
client
.
queryStage
==
QueryStage
::
QueryingLostConfig
&&
resp
.
parse
(
zones
,
hasMore
))
{
if
(
client
.
queryStage
==
QueryStage
::
QueryingLostConfig
&&
resp
.
parse
(
zones
,
hasMore
))
{
...
@@ -300,7 +300,7 @@ void handle_com_passthrough(ThreadContext* context, Client& client, evbuffer* ou
...
@@ -300,7 +300,7 @@ void handle_com_passthrough(ThreadContext* context, Client& client, evbuffer* ou
}
}
XDataPtr
xdata
;
XDataPtr
xdata
;
if
(
hasMore
)
{
// 继续索要剩余防区
if
(
hasMore
)
{
// 继续索要剩余防区
com
::
A2
req
;
com
::
Req_
A2
req
;
xdata
=
makeXData
((
const
char
*
)
req
.
data
,
req
.
len
);
xdata
=
makeXData
((
const
char
*
)
req
.
data
,
req
.
len
);
auto
n
=
context
->
packet
.
make_hb
(
buf
,
sizeof
(
buf
),
client
.
nextSeq
(),
client
.
acct
,
client
.
ademco_id
,
0
,
auto
n
=
context
->
packet
.
make_hb
(
buf
,
sizeof
(
buf
),
client
.
nextSeq
(),
client
.
acct
,
client
.
ademco_id
,
0
,
EVENT_COM_PASSTHROUGH
,
0
,
xdata
);
EVENT_COM_PASSTHROUGH
,
0
,
xdata
);
...
@@ -327,7 +327,7 @@ void handle_com_passthrough(ThreadContext* context, Client& client, evbuffer* ou
...
@@ -327,7 +327,7 @@ void handle_com_passthrough(ThreadContext* context, Client& client, evbuffer* ou
break
;
break
;
case
com
:
:
ResponseParser
::
ResponseType
::
B1_response
:
case
com
:
:
ResponseParser
::
ResponseType
::
B1_response
:
{
{
com
::
B1R
b1
;
memcpy
(
b1
.
data
.
data
,
xdata
.
data
(),
xdata
.
size
());
com
::
Resp_B1
b1
;
memcpy
(
b1
.
data
.
data
,
xdata
.
data
(),
xdata
.
size
());
client
.
status1
=
b1
.
data
.
cmd
.
status1
==
0
?
MachineStatus
::
Arm
:
MachineStatus
::
Disarm
;
client
.
status1
=
b1
.
data
.
cmd
.
status1
==
0
?
MachineStatus
::
Arm
:
MachineStatus
::
Disarm
;
client
.
status2
=
b1
.
data
.
cmd
.
status2
==
0
?
MachineStatus
::
Arm
:
MachineStatus
::
Disarm
;
client
.
status2
=
b1
.
data
.
cmd
.
status2
==
0
?
MachineStatus
::
Arm
:
MachineStatus
::
Disarm
;
client
.
status3
=
b1
.
data
.
cmd
.
status3
==
0
?
MachineStatus
::
Arm
:
MachineStatus
::
Disarm
;
client
.
status3
=
b1
.
data
.
cmd
.
status3
==
0
?
MachineStatus
::
Arm
:
MachineStatus
::
Disarm
;
...
@@ -367,7 +367,7 @@ void handle_ademco_msg(ThreadContext* context, bufferevent* bev)
...
@@ -367,7 +367,7 @@ void handle_ademco_msg(ThreadContext* context, bufferevent* bev)
if
(
ademco
::
isMachineTypeEvent
(
context
->
packet
.
ademcoData_
.
ademco_event_
))
{
if
(
ademco
::
isMachineTypeEvent
(
context
->
packet
.
ademcoData_
.
ademco_event_
))
{
client
.
type
=
context
->
packet
.
ademcoData_
.
ademco_event_
;
client
.
type
=
context
->
packet
.
ademcoData_
.
ademco_event_
;
if
(
client
.
type
==
EVENT_I_AM_3_SECTION_MACHINE
)
{
// 三区段主机需要主动索要主机状态
if
(
client
.
type
==
EVENT_I_AM_3_SECTION_MACHINE
)
{
// 三区段主机需要主动索要主机状态
com
::
B0
req
;
com
::
Req_
B0
req
;
auto
xdata
=
makeXData
((
const
char
*
)
req
.
data
,
req
.
len
);
auto
xdata
=
makeXData
((
const
char
*
)
req
.
data
,
req
.
len
);
auto
n
=
context
->
packet
.
make_hb
(
buf
,
sizeof
(
buf
),
client
.
nextSeq
(),
client
.
acct
,
client
.
ademco_id
,
0
,
auto
n
=
context
->
packet
.
make_hb
(
buf
,
sizeof
(
buf
),
client
.
nextSeq
(),
client
.
acct
,
client
.
ademco_id
,
0
,
EVENT_COM_PASSTHROUGH
,
0
,
xdata
);
EVENT_COM_PASSTHROUGH
,
0
,
xdata
);
...
@@ -392,7 +392,7 @@ void handle_ademco_msg(ThreadContext* context, bufferevent* bev)
...
@@ -392,7 +392,7 @@ void handle_ademco_msg(ThreadContext* context, bufferevent* bev)
}
else
if
(
context
->
packet
.
ademcoData_
.
ademco_event_
==
EVENT_ENTER_SET_MODE
)
{
}
else
if
(
context
->
packet
.
ademcoData_
.
ademco_event_
==
EVENT_ENTER_SET_MODE
)
{
if
(
client
.
queryStage
==
QueryStage
::
WaitingSettingsMode
)
{
if
(
client
.
queryStage
==
QueryStage
::
WaitingSettingsMode
)
{
client
.
queryStage
=
QueryStage
::
QueryingZones
;
client
.
queryStage
=
QueryStage
::
QueryingZones
;
com
::
A1
req
;
com
::
Req_
A1
req
;
auto
xdata
=
makeXData
((
const
char
*
)
req
.
data
,
req
.
len
);
auto
xdata
=
makeXData
((
const
char
*
)
req
.
data
,
req
.
len
);
auto
n
=
context
->
packet
.
make_hb
(
buf
,
sizeof
(
buf
),
client
.
nextSeq
(),
client
.
acct
,
client
.
ademco_id
,
0
,
auto
n
=
context
->
packet
.
make_hb
(
buf
,
sizeof
(
buf
),
client
.
nextSeq
(),
client
.
acct
,
client
.
ademco_id
,
0
,
EVENT_COM_PASSTHROUGH
,
0
,
xdata
);
EVENT_COM_PASSTHROUGH
,
0
,
xdata
);
...
@@ -404,7 +404,7 @@ void handle_ademco_msg(ThreadContext* context, bufferevent* bev)
...
@@ -404,7 +404,7 @@ void handle_ademco_msg(ThreadContext* context, bufferevent* bev)
}
}
}
else
if
(
client
.
queryStage
==
QueryStage
::
WaitingSettingsMode2
)
{
}
else
if
(
client
.
queryStage
==
QueryStage
::
WaitingSettingsMode2
)
{
client
.
queryStage
=
QueryStage
::
QueryingTimer
;
client
.
queryStage
=
QueryStage
::
QueryingTimer
;
com
::
A5
req
;
com
::
Req_
A5
req
;
auto
xdata
=
makeXData
((
const
char
*
)
req
.
data
,
req
.
len
);
auto
xdata
=
makeXData
((
const
char
*
)
req
.
data
,
req
.
len
);
auto
n
=
context
->
packet
.
make_hb
(
buf
,
sizeof
(
buf
),
client
.
nextSeq
(),
client
.
acct
,
client
.
ademco_id
,
0
,
auto
n
=
context
->
packet
.
make_hb
(
buf
,
sizeof
(
buf
),
client
.
nextSeq
(),
client
.
acct
,
client
.
ademco_id
,
0
,
EVENT_COM_PASSTHROUGH
,
0
,
xdata
);
EVENT_COM_PASSTHROUGH
,
0
,
xdata
);
...
...
include/hb_detail.h
View file @
19290bbb
This diff is collapsed.
Click to expand it.
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