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
6e247767
Commit
6e247767
authored
Aug 10, 2020
by
尹佳钦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去除 json中mac条目的0x
parent
5f1910e5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
31 deletions
+34
-31
platform/zigbee/app/builder/Z3GatewayHost/jsonrpc/jsonrpc-c.c
...form/zigbee/app/builder/Z3GatewayHost/jsonrpc/jsonrpc-c.c
+4
-3
platform/zigbee/app/builder/Z3GatewayHost/jsonrpc/jsonrpc-c.h
...form/zigbee/app/builder/Z3GatewayHost/jsonrpc/jsonrpc-c.h
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
+6
-7
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
+1
-3
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_common.c
...zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_common.c
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
...p/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
+21
-16
No files found.
platform/zigbee/app/builder/Z3GatewayHost/jsonrpc/jsonrpc-c.c
View file @
6e247767
...
...
@@ -73,7 +73,7 @@ static int send_result(struct jrpc_connection * conn, cJSON * result,
}
static
int
invoke_procedure
(
struct
jrpc_server
*
server
,
struct
jrpc_connection
*
conn
,
char
*
name
,
cJSON
*
params
,
cJSON
*
id
)
{
struct
jrpc_connection
*
conn
,
char
*
name
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
)
{
cJSON
*
returned
=
NULL
;
int
procedure_found
=
0
;
jrpc_context
ctx
;
...
...
@@ -84,7 +84,7 @@ static int invoke_procedure(struct jrpc_server *server,
if
(
!
strcmp
(
server
->
procedures
[
i
].
name
,
name
))
{
procedure_found
=
1
;
ctx
.
data
=
server
->
procedures
[
i
].
data
;
returned
=
server
->
procedures
[
i
].
function
(
&
ctx
,
params
,
id
);
returned
=
server
->
procedures
[
i
].
function
(
&
ctx
,
params
,
id
,
mac
);
break
;
}
}
...
...
@@ -119,8 +119,9 @@ static int eval_request(struct jrpc_server *server,
rpc_cJSON_CreateNumber
(
id
->
valueint
);
if
(
server
->
debug_level
)
printf
(
"Method Invoked[2]: %s
\n
"
,
method
->
valuestring
);
cJSON
*
mac
=
NULL
;
return
invoke_procedure
(
server
,
conn
,
method
->
valuestring
,
params
,
id_copy
);
params
,
id_copy
,
mac
);
}
}
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/jsonrpc/jsonrpc-c.h
View file @
6e247767
...
...
@@ -37,7 +37,7 @@ typedef struct {
char
*
error_message
;
}
jrpc_context
;
typedef
cJSON
*
(
*
jrpc_function
)(
jrpc_context
*
context
,
cJSON
*
params
,
cJSON
*
id
);
typedef
cJSON
*
(
*
jrpc_function
)(
jrpc_context
*
context
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
struct
jrpc_procedure
{
char
*
name
;
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
View file @
6e247767
...
...
@@ -73,7 +73,7 @@ bool kk_rpc_report_LightStatus(EmberEUI64 mac,bool LightStatus)
cJSON
*
rpc_Control
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
cJSON
*
rpc_Control
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
)
{
rpc_nwk_info_s
info
;
EmberStatus
status
;
...
...
@@ -82,18 +82,17 @@ cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id)
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
cJSON
*
mac_item
=
rpc_cJSON_GetObjectItem
(
params
,
"mac"
);
cJSON
*
LightStatus_item
=
rpc_cJSON_GetObjectItem
(
params
,
"LightStatus"
);
uint8_t
LightStatus
=
rpc_get_u8
(
LightStatus_item
->
valuestring
);
uint8_t
mac
[
EUI64_SIZE
];
bool
flag
=
rpc_get_mac
(
mac
_item
->
valuestring
,
mac
);
emberAfCorePrintBuffer
(
mac
,
EUI64_SIZE
,
true
);
uint8_t
eui64
[
EUI64_SIZE
];
bool
flag
=
rpc_get_mac
(
mac
->
valuestring
,
eui64
);
emberAfCorePrintBuffer
(
eui64
,
EUI64_SIZE
,
true
);
for
(
int
i
=
0
;
i
<
EUI64_SIZE
;
i
++
){
emberAfCorePrintln
(
"i=%d,val=%02x"
,
i
,
mac
[
i
]);
emberAfCorePrintln
(
"i=%d,val=%02x"
,
i
,
eui64
[
i
]);
}
EmberNodeId
node
=
emberAfDeviceTableGetNodeIdFromEui64
(
mac
);
EmberNodeId
node
=
emberAfDeviceTableGetNodeIdFromEui64
(
eui64
);
if
(
node
==
0xffff
){
emberAfCorePrintln
(
"
\r\n
not find device!
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
View file @
6e247767
...
...
@@ -11,9 +11,7 @@
#define KK_REPORT_ATTRIBUTE_METHOD "thing.service.property.report"
cJSON
*
rpc_Control
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_Control
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_common.c
View file @
6e247767
...
...
@@ -395,7 +395,7 @@ void rpc_printfJSON(char* str,cJSON* item)
void
rpc_eui64ToString
(
EmberEUI64
eui
,
char
*
euiString
)
{
sprintf
(
euiString
,
"
0x
%02X%02X%02X%02X%02X%02X%02X%02X"
,
sprintf
(
euiString
,
"%02X%02X%02X%02X%02X%02X%02X%02X"
,
eui
[
7
],
eui
[
6
],
eui
[
5
],
...
...
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
View file @
6e247767
...
...
@@ -90,8 +90,10 @@ static int send_result_resp(cJSON * result,
cJSON
*
result_root
=
rpc_cJSON_CreateObject
();
if
(
result
)
rpc_cJSON_AddItemToObject
(
result_root
,
"code"
,
result
);
if
(
id
){
printf
(
"id json:
\n
%s
\n
"
,
id
->
valuestring
);
rpc_cJSON_AddItemToObject
(
result_root
,
"msgId"
,
id
);
}
char
*
str_result
=
rpc_cJSON_Print
(
result_root
);
printf
(
"send json:
\n
%s
\n
"
,
str_result
);
...
...
@@ -122,7 +124,7 @@ static int send_error_resp(int code, char* message,
}
static
int
invoke_procedure
(
struct
jrpc_server
*
server
,
char
*
name
,
cJSON
*
params
,
cJSON
*
id
)
{
char
*
name
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
)
{
cJSON
*
returned
=
NULL
;
int
procedure_found
=
0
;
jrpc_context
ctx
;
...
...
@@ -133,7 +135,7 @@ static int invoke_procedure(struct jrpc_server *server,
if
(
!
strcmp
(
server
->
procedures
[
i
].
name
,
name
))
{
procedure_found
=
1
;
ctx
.
data
=
server
->
procedures
[
i
].
data
;
returned
=
server
->
procedures
[
i
].
function
(
&
ctx
,
params
,
id
);
returned
=
server
->
procedures
[
i
].
function
(
&
ctx
,
params
,
id
,
mac
);
break
;
}
}
...
...
@@ -149,7 +151,7 @@ static int invoke_procedure(struct jrpc_server *server,
}
static
int
eval_request
(
struct
jrpc_server
*
server
,
cJSON
*
root
)
{
cJSON
*
method
,
*
params
,
*
id
;
cJSON
*
method
,
*
params
,
*
id
,
*
mac
;
method
=
rpc_cJSON_GetObjectItem
(
root
,
"method"
);
if
(
method
!=
NULL
&&
method
->
type
==
cJSON_String
)
{
params
=
rpc_cJSON_GetObjectItem
(
root
,
"params"
);
...
...
@@ -158,6 +160,8 @@ static int eval_request(struct jrpc_server *server, cJSON *root) {
id
=
rpc_cJSON_GetObjectItem
(
root
,
"msgId"
);
if
(
id
==
NULL
||
id
->
type
==
cJSON_String
||
id
->
type
==
cJSON_Number
)
{
mac
=
rpc_cJSON_GetObjectItem
(
root
,
"mac"
);
if
(
mac
->
type
=
cJSON_String
){
//We have to copy ID because using it on the reply and deleting the response Object will also delete ID
cJSON
*
id_copy
=
NULL
;
if
(
id
!=
NULL
)
...
...
@@ -168,7 +172,8 @@ static int eval_request(struct jrpc_server *server, cJSON *root) {
if
(
server
->
debug_level
)
printf
(
"Method Invoked[2]: %s
\n
"
,
method
->
valuestring
);
return
invoke_procedure
(
server
,
method
->
valuestring
,
params
,
id_copy
);
params
,
id_copy
,
mac
);
}
}
}
}
...
...
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