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
61d21d6c
Commit
61d21d6c
authored
Aug 08, 2020
by
黄振令
Browse files
Options
Browse Files
Download
Plain Diff
【修改内容】1. 根据topic过滤, get 不会把命令传到platform ;2.set 属性midware 做反馈给云端
【提交人】黄振令
parents
5a794539
ae347f12
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
27 deletions
+25
-27
midware/midware/midware.c
midware/midware/midware.c
+25
-27
No files found.
midware/midware/midware.c
View file @
61d21d6c
...
@@ -21,19 +21,9 @@
...
@@ -21,19 +21,9 @@
void
mid_cb
(
void
*
data
,
int
len
){
void
mid_cb
(
void
*
data
,
int
len
){
if
(
data
!=
NULL
){
if
(
data
!=
NULL
){
printf
(
"app2mid_cb: %s RECEIVED
\r\n
"
,
data
);
printf
(
"app2mid_cb: %s RECEIVED
\r\n
"
,
data
);
char
*
out
;
char
*
out
;
cJSON
*
json
,
*
topic
,
*
payload
;
cJSON
*
json
;
cJSON
*
topic
;
cJSON
*
payload
;
int
res
;
int
res
;
void
*
buf
=
malloc
(
len
);
memcpy
(
buf
,
data
,
len
);
res
=
dm_queue_msg_insert
((
void
*
)
buf
);
if
(
res
!=
SUCCESS_RETURN
)
{
free
(
buf
);
}
json
=
cJSON_Parse
(
data
);
json
=
cJSON_Parse
(
data
);
if
(
!
json
)
{
if
(
!
json
)
{
printf
(
"Error before: [%s]
\n
"
,
"cJSON_Parse"
);
printf
(
"Error before: [%s]
\n
"
,
"cJSON_Parse"
);
...
@@ -43,12 +33,25 @@ void mid_cb(void* data, int len){
...
@@ -43,12 +33,25 @@ void mid_cb(void* data, int len){
topic
=
cJSON_GetObjectItem
(
json
,
"topic"
);
topic
=
cJSON_GetObjectItem
(
json
,
"topic"
);
payload
=
cJSON_GetObjectItem
(
json
,
"payload"
);
payload
=
cJSON_GetObjectItem
(
json
,
"payload"
);
printf
(
"mid_cb topic: [%s] ,payload= %s
\n
"
,
topic
->
valuestring
,
payload
->
valuestring
);
printf
(
"mid_cb topic: [%s] ,payload= %s
\n
"
,
topic
->
valuestring
,
payload
->
valuestring
);
if
(
strstr
(
topic
->
valuestring
,
"thing/service"
)
!=
NULL
&&
strstr
(
topic
->
valuestring
,
"service/property/get"
)
==
NULL
){
if
(
strcmp
(
payload
->
valuestring
,
"addsub"
)
==
0
){
//set to platform
//kk_mid_subdev_add("a1OYuSallan","allanWno8yDdsjCX15iq","");
}
else
{
void
*
buf
=
malloc
(
len
);
memcpy
(
buf
,
data
,
len
);
int
res
=
dm_queue_msg_insert
((
void
*
)
buf
);
if
(
res
!=
SUCCESS_RETURN
)
{
free
(
buf
);
//return FAIL_RETURN;
}
//kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL);
}
char
mac
[
DEVICE_MAC_MAXLEN
];
char
mac
[
DEVICE_MAC_MAXLEN
];
res
=
dm_mgr_search_mac_by_topic
(
topic
->
valuestring
,
mac
);
res
=
dm_mgr_search_mac_by_topic
(
topic
->
valuestring
,
mac
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
printf
(
"mid_cb dm_mgr_search_mac_by_topic mac: %s
\r\n
"
,
mac
);
return
;
}
printf
(
"dm_mgr_search_mac_by_topic mac: %s
\r\n
"
,
mac
);
cJSON
*
jsonplay
=
cJSON_Parse
(
payload
->
valuestring
);
cJSON
*
jsonplay
=
cJSON_Parse
(
payload
->
valuestring
);
cJSON_AddStringToObject
(
jsonplay
,
"mac"
,
mac
);
cJSON_AddStringToObject
(
jsonplay
,
"mac"
,
mac
);
...
@@ -56,11 +59,6 @@ void mid_cb(void* data, int len){
...
@@ -56,11 +59,6 @@ void mid_cb(void* data, int len){
kk_ipc_send
(
IPC_MID2PLAT
,
out
,
strlen
(
out
));
kk_ipc_send
(
IPC_MID2PLAT
,
out
,
strlen
(
out
));
free
(
out
);
free
(
out
);
cJSON_Delete
(
jsonplay
);
cJSON_Delete
(
jsonplay
);
}
}
cJSON_Delete
(
json
);
cJSON_Delete
(
json
);
}
}
...
@@ -116,7 +114,7 @@ void kk_platMsg_handle(void* data){
...
@@ -116,7 +114,7 @@ void kk_platMsg_handle(void* data){
}
else
if
(
method
!=
NULL
&&
strcmp
(
method
->
valuestring
,
"thing.event.property.post"
)
==
0
){
}
else
if
(
method
!=
NULL
&&
strcmp
(
method
->
valuestring
,
"thing.event.property.post"
)
==
0
){
cJSON
*
mac
;
cJSON
*
mac
;
mac
=
cJSON_GetObjectItem
(
json
,
"mac"
);
mac
=
cJSON_GetObjectItem
(
json
,
"mac"
);
kk_tsl_property_set_byMac
(
mac
->
valuestring
,
data
,
strlen
(
mac
)
+
1
,
NULL
);
//kk_tsl_service_property_set(topic->valuestring, data, strlen(data), NULL);
//kk_tsl_service_property_set(topic->valuestring, data, strlen(data), NULL);
...
...
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