Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
k-sdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈伟灿
k-sdk
Commits
07ca1ed8
Commit
07ca1ed8
authored
Aug 28, 2020
by
黄振令
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】1. 整理网关添加topo代码;2. 增加网关连接成功后,发送网关状态
【提交人】huang.zhenling
parent
88f4925a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
12 deletions
+45
-12
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
...p/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
+45
-12
No files found.
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
View file @
07ca1ed8
...
@@ -217,7 +217,7 @@ static int eval_request(struct jrpc_server *server, cJSON *root) {
...
@@ -217,7 +217,7 @@ static int eval_request(struct jrpc_server *server, cJSON *root) {
void
_cb
(
void
*
data
){
void
_cb
(
void
*
data
){
if
(
data
!=
NULL
){
if
(
data
!=
NULL
){
printf
(
"plat2mid_cb: %s RECEIVED
\r\n
"
,
data
);
//
printf("plat2mid_cb: %s RECEIVED \r\n", data);
cJSON
*
root
;
cJSON
*
root
;
char
*
end_ptr
=
NULL
;
char
*
end_ptr
=
NULL
;
...
@@ -424,6 +424,39 @@ int search_ccu(char devcode[33], char ip[16], int* port){
...
@@ -424,6 +424,39 @@ int search_ccu(char devcode[33], char ip[16], int* port){
}
}
#define GW_PRODUCT_CODE "2"
#define GW_MAC GW_DEVICE_CODE
void
*
_msg_topo_add
(){
char
msgFmt
[]
=
"{
\"
info
\"
:{
\"
msgtype
\"
:
\"
/thing/topo/add
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
},\
\"
payload
\"
:{
\"
msgId
\"
:
\"
%d
\"
,
\"
version
\"
:
\"
1.0
\"
,
\"
params
\"
:{
\"
deviceCode
\"
:
\"
%s
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
mac
\"
:
\"
%s
\"
}}}"
;
char
msg
[
520
]
=
{
0
};
sprintf
(
msg
,
msgFmt
,
GW_PRODUCT_CODE
,
GW_DEVICE_CODE
,
1
,
GW_DEVICE_CODE
,
GW_PRODUCT_CODE
,
GW_MAC
);
cJSON
*
msgObj
=
cJSON_Parse
(
msg
);
char
*
outbuf
=
cJSON_Print
(
msgObj
);
cJSON_Delete
(
msgObj
);
return
outbuf
;
}
void
*
_msg_event_property_post
(
char
ip
[
16
],
int
port
){
char
msgFmt
[]
=
"{
\"
info
\"
:{
\"
msgtype
\"
:
\"
/thing/event/property/post
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
},\
\"
payload
\"
:{
\"
msgId
\"
:
\"
%d
\"
,
\"
version
\"
:
\"
1.0
\"
,
\"
params
\"
:{
\"
NetChannelState
\"
:%d,
\"
WhiteListState
\"
:%d,\
\"
OnlineDetectionState
\"
:%d,
\"
SN
\"
:
\"
%s
\"
,
\"
IPAddress
\"
:
\"
%s
\"
,
\"
MACAddress
\"
:
\"
%s
\"
,
\"
Port
\"
:%d},\
\"
time
\"
:1524448722000,
\"
method
\"
:
\"
thing.event.property.post
\"
}\
}"
;
char
msg
[
620
]
=
{
0
};
sprintf
(
msg
,
msgFmt
,
GW_PRODUCT_CODE
,
GW_DEVICE_CODE
,
1
,
0
,
0
,
0
,
"12345"
,
ip
,
GW_MAC
,
port
);
cJSON
*
msgObj
=
cJSON_Parse
(
msg
);
char
*
outbuf
=
cJSON_Print
(
msgObj
);
cJSON_Delete
(
msgObj
);
return
outbuf
;
}
void
ipcHandle
(
void
)
void
ipcHandle
(
void
)
{
{
char
deviceCode
[
33
]
=
{
0
};
char
deviceCode
[
33
]
=
{
0
};
...
@@ -445,23 +478,23 @@ void ipcHandle(void)
...
@@ -445,23 +478,23 @@ void ipcHandle(void)
}
}
//send add gw to ccu
//send add gw to ccu
char
info
[]
=
"{
\"
msgtype
\"
:
\"
/thing/topo/add
\"
,
\"
productType
\"
:
\"
gw
\"
,
\"
productCode
\"
:
\"
2
\"
,
\"
deviceCode
\"
:
\"
1122334455667788
\"
}"
;
char
*
outbuf
=
_msg_topo_add
();
char
payload
[]
=
"{
\"
msgId
\"
:
\"
1
\"
,
\"
version
\"
:
\"
1.0
\"
,
\"
params
\"
:{
\"
deviceCode
\"
:
\"
1122334455667788
\"
,
\"
productCode
\"
:
\"
2
\"
,
\"
mac
\"
:
\"
1122334455667788
\"
}}"
;
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
infoObj
=
cJSON_Parse
(
info
);
cJSON
*
payloadObj
=
cJSON_Parse
(
payload
);
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
char
*
outbuf
=
cJSON_Print
(
root
);
cJSON_Delete
(
root
);
kk_sendData2CCU
(
outbuf
,
strlen
(
outbuf
));
kk_sendData2CCU
(
outbuf
,
strlen
(
outbuf
));
//kk_sendData2CCU("allan test", strlen("allan test"));
free
(
outbuf
);
free
(
outbuf
);
int
cnt
=
0
;
//handle procidure
//handle procidure
while
(
1
){
while
(
1
){
//
//
usleep
(
20000
);
usleep
(
20000
);
cnt
++
;
if
(
cnt
==
2
){
sleep
(
1
);
char
*
postmsg
=
_msg_event_property_post
(
ip
,
port
);
kk_sendData2CCU
(
postmsg
,
strlen
(
postmsg
));
free
(
postmsg
);
}
}
}
//jrpc_server_run(&my_server);
//jrpc_server_run(&my_server);
...
...
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