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
89a95333
Commit
89a95333
authored
Sep 04, 2020
by
黄振令
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】1. 网关连接主机失败,重现广播发现,解决主机ip地址变了无法连接问题;2.优化nnmsg代码
【提交人】huang.zhenling
parent
4d5b2765
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
17 deletions
+83
-17
common/api/com_api.c
common/api/com_api.c
+43
-11
common/api/com_api.h
common/api/com_api.h
+1
-1
common/api/tcp_channel.c
common/api/tcp_channel.c
+2
-2
platform/zigbee/app/builder/Z3GatewayHost/com_api.h
platform/zigbee/app/builder/Z3GatewayHost/com_api.h
+4
-3
platform/zigbee/app/builder/Z3GatewayHost/libapi_com_ubuntu.so
...orm/zigbee/app/builder/Z3GatewayHost/libapi_com_ubuntu.so
+0
-0
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
...p/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
+33
-0
No files found.
common/api/com_api.c
View file @
89a95333
...
...
@@ -6,6 +6,8 @@
#define GW2CCU_PIPE "tcp://%s:5555"
#define GW2CCU_PUBSUB "tcp://%s:5557"
#define MAGIC "magic12"
#define MAGIC_ACK "magic12ack"
#define FILTERSTR "|"
#ifndef _ZLOG_
...
...
@@ -36,6 +38,7 @@ typedef struct {
ipc_cb
*
cb
;
ipc_type
type
;
int
isconnect
;
int
sendErrCnt
;
}
Bloop_ctrl_t
;
...
...
@@ -84,10 +87,12 @@ static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents)
}
if
(
bytes
<=
0
||
dat
==
NULL
)
{
ERROR_PRINT
(
" recived data is null or len is 0
\n
"
);
ERROR_PRINT
(
"nn_recv failed with error code %d, %s
\n
"
,
nn_errno
(),
nn_strerror
(
nn_errno
()));
return
;
}
INFO_PRINT
(
"watcher_cb:%s recived
\r\n\r\n
"
,
(
char
*
)
dat
);
loop_ctrl
->
isconnect
=
1
;
//if sub, need filter sbuscribe str
if
(
IPC_PLAT2MID
==
loop_ctrl
->
type
||
IPC_MID2PLAT
==
loop_ctrl
->
type
){
validDat
=
_parse_data_by_subscribe
(
dat
,
bytes
,
&
validLen
,
&
chlMark
);
...
...
@@ -106,10 +111,13 @@ static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents)
}
}*/
if
(
strncmp
(
validDat
,
MAGIC
,
strlen
(
MAGIC
))
==
0
){
if
(
loop_ctrl
->
isconnect
==
0
){
kk_ipc_send_ex
(
loop_ctrl
->
type
,
validDat
,
bytes
,
chlMark
);
loop_ctrl
->
isconnect
=
1
;
if
(
strncmp
(
validDat
,
MAGIC_ACK
,
strlen
(
MAGIC_ACK
))
==
0
){
}
else
{
kk_ipc_send_ex
(
loop_ctrl
->
type
,
MAGIC_ACK
,
strlen
(
MAGIC_ACK
)
+
1
,
chlMark
);
}
loop_ctrl
->
isconnect
=
1
;
nn_freemsg
(
dat
);
return
;
}
else
if
(
IPC_MID2PLAT
==
loop_ctrl
->
type
){
//
...
...
@@ -132,7 +140,7 @@ void __loop_init(Bloop_ctrl_t *loop_ctrl, struct ev_loop* loop)
}
else
{
ev_io_init
(
&
(
loop_ctrl
->
watcher
),
watcher_cb
,
loop_ctrl
->
ba
.
s
,
EV_READ
);
}
ev_io_start
(
loop
,
&
(
loop_ctrl
->
watcher
));
}
...
...
@@ -335,7 +343,7 @@ int kk_ipc_init(ipc_type type, ipc_cb cb, char* chlMark, char* ip)
}
int
kk_ipc_dinit
(
ipc_type
type
)
int
kk_ipc_d
e
init
(
ipc_type
type
)
{
Bloop_ctrl_t
*
loop_ctrl
;
if
(
Bloop_ctrl
.
type
==
type
){
...
...
@@ -389,10 +397,11 @@ int kk_ipc_send(ipc_type type, void* data, int len)
int
kk_ipc_send_ex
(
ipc_type
type
,
void
*
data
,
int
len
,
char
*
chalMark
)
{
int
ret
=
0
;
if
(
data
!=
NULL
){
int
filterlen
=
0
;
void
*
buf
=
NULL
;
Bloop_ctrl_t
*
loop_ctrl
;
if
(
chalMark
!=
NULL
){
filterlen
=
strlen
(
chalMark
)
+
strlen
(
FILTERSTR
);
...
...
@@ -410,9 +419,21 @@ int kk_ipc_send_ex(ipc_type type, void* data, int len, char* chalMark)
memcpy
(
buf
+
filterlen
,
data
,
len
);
if
(
type
==
IPC_MID2PLAT
){
nn_send
(
Mloop_ctrl
.
ab
.
n
,
&
buf
,
NN_MSG
,
NN_DONTWAIT
);
//NN_DONTWAIT
loop_ctrl
=
&
Mloop_ctrl
;
ret
=
nn_send
(
Mloop_ctrl
.
ab
.
n
,
&
buf
,
NN_MSG
,
NN_DONTWAIT
);
//NN_DONTWAIT
}
else
{
loop_ctrl
=
&
Bloop_ctrl
;
ret
=
nn_send
(
Bloop_ctrl
.
ba
.
n
,
&
buf
,
NN_MSG
,
NN_DONTWAIT
);
}
if
(
ret
<
0
){
ERROR_PRINT
(
"nn_send failed with error code %d, str=%s
\n
"
,
nn_errno
(),
nn_strerror
(
nn_errno
()));
loop_ctrl
->
sendErrCnt
++
;
loop_ctrl
->
isconnect
=
0
;
nn_freemsg
(
buf
);
}
else
{
nn_send
(
Bloop_ctrl
.
ba
.
n
,
&
buf
,
NN_MSG
,
NN_DONTWAIT
);
loop_ctrl
->
sendErrCnt
=
0
;
loop_ctrl
->
isconnect
=
1
;
}
}
...
...
@@ -421,6 +442,18 @@ int kk_ipc_send_ex(ipc_type type, void* data, int len, char* chalMark)
}
int
kk_ipc_get_senderrcnt
(
ipc_type
type
){
Bloop_ctrl_t
*
loop_ctrl
;
if
(
IPC_MID2PLAT
==
type
){
loop_ctrl
=
&
Mloop_ctrl
;
}
else
{
loop_ctrl
=
&
Bloop_ctrl
;
}
return
loop_ctrl
->
sendErrCnt
;
}
int
kk_ipc_isconnect
(
ipc_type
type
){
Bloop_ctrl_t
*
loop_ctrl
;
...
...
@@ -430,9 +463,8 @@ int kk_ipc_isconnect(ipc_type type){
loop_ctrl
=
&
Bloop_ctrl
;
}
if
(
loop_ctrl
->
isconnect
==
1
){
return
1
;
}
else
{
loop_ctrl
->
isconnect
=
0
;
{
for
(
int
i
=
0
;
i
<
20
;
i
++
){
kk_ipc_send
(
type
,
MAGIC
,
strlen
(
MAGIC
)
+
1
);
...
...
common/api/com_api.h
View file @
89a95333
...
...
@@ -40,7 +40,7 @@ typedef enum {
typedef
void
ipc_cb
(
void
*
data
,
int
len
,
char
*
chalMark
);
int
kk_ipc_init
(
ipc_type
type
,
ipc_cb
cb
,
char
*
chalMark
,
char
*
ip
);
int
kk_ipc_dinit
();
int
kk_ipc_d
e
init
();
int
kk_ipc_send
(
ipc_type
type
,
void
*
data
,
int
len
);
int
kk_ipc_send_ex
(
ipc_type
type
,
void
*
data
,
int
len
,
char
*
chalMark
);
...
...
common/api/tcp_channel.c
View file @
89a95333
...
...
@@ -193,8 +193,8 @@ int kk_is_tcp_channel(char devCode[DEVICE_CODE_LEN]){
for
(;
i
<
MAX_LISTEN_NUM
;
i
++
){
if
(
strcmp
(
devCode
,
g_tcp_ctrl
[
i
].
deviceCode
)
==
0
){
printf
(
"[%s] idx=%d ip=%s sock=%d
\n
"
,
__FUNCTION__
,
i
,
devCode
,
g_tcp_ctrl
[
i
].
sock
);
return
i
;
printf
(
"[%s] idx=%d ip=%s sock=%d
\n
"
,
__FUNCTION__
,
i
,
g_tcp_ctrl
[
i
].
ip
,
g_tcp_ctrl
[
i
].
sock
);
return
g_tcp_ctrl
[
i
].
sock
;
}
}
return
-
1
;
...
...
platform/zigbee/app/builder/Z3GatewayHost/com_api.h
View file @
89a95333
...
...
@@ -28,18 +28,19 @@ typedef enum {
IPC_UNDEF
}
ipc_type
;
#define MSG_TYPE_STR "msgtype"
#define MSG_PRODUCT_TYPE_STR "productType"
#define MSG_PRODUCT_CODE_STR "productCode"
#define MSG_DEVICE_CODE_STR "deviceCode"
#define MSG_PAYLOAD_STR "payload"
#define MSG_INFO_STR "info"
#define MSG_INDENTIFIER_STR "identifier"
#define MSG_INDENTIFIER_STR "identifier"
#define MSG_PARAMS_STR "params"
#define MSG_IOTClOUDSTATE_STR "IOTCloudState"
typedef
void
ipc_cb
(
void
*
data
,
int
len
,
char
*
chalMark
);
int
kk_ipc_init
(
ipc_type
type
,
ipc_cb
cb
,
char
*
chalMark
,
char
*
ip
);
int
kk_ipc_dinit
();
int
kk_ipc_d
e
init
();
int
kk_ipc_send
(
ipc_type
type
,
void
*
data
,
int
len
);
int
kk_ipc_send_ex
(
ipc_type
type
,
void
*
data
,
int
len
,
char
*
chalMark
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/libapi_com_ubuntu.so
View file @
89a95333
No preview for this file type
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
View file @
89a95333
...
...
@@ -495,6 +495,16 @@ void* _msg_event_property_post(char ip[16], int port){
}
int
kk_connect_check
(){
if
(
strcmp
(
GW2CCU_PROTOCOL
,
"tcp"
)
==
0
){
return
kk_get_retry_num
()
>
20
;
}
else
{
if
(
kk_ipc_get_senderrcnt
(
IPC_PLAT2MID
)
>
0
){
return
kk_ipc_isconnect
(
IPC_PLAT2MID
)
==
0
?
1
:
0
;
}
return
0
;
}
}
void
ipcHandle
(
void
)
{
...
...
@@ -553,6 +563,29 @@ void ipcHandle(void)
kk_sendData2CCU
(
postmsg
,
strlen
(
postmsg
));
free
(
postmsg
);
}
if
(
kk_connect_check
()){
//discover ccu
search_ccu
(
deviceCode
,
ip
,
&
port
);
if
(
strcmp
(
GW2CCU_PROTOCOL
,
"tcp"
)
==
0
){
kk_tcp_client_init
(
ip
,
port
,
_cb
);
}
else
{
kk_ipc_deinit
(
IPC_PLAT2MID
);
kk_ipc_init
(
IPC_PLAT2MID
,
_cb
,
macString
/*GW_DEVICE_CODE*/
,
ip
);
}
//send add gw to ccu
outbuf
=
_msg_topo_add
();
if
(
outbuf
==
NULL
){
printf
(
"[%s] topo add msg failed, exit
\n
"
,
__FUNCTION__
);
return
;
}
kk_sendData2CCU
(
outbuf
,
strlen
(
outbuf
));
free
(
outbuf
);
cnt
=
0
;
kk_reset_retry_num
();
}
}
...
...
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