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
0d796981
Commit
0d796981
authored
Aug 26, 2020
by
黄振令
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】1. 通过info里的deviceCode与payload里的deviceCode来区分添加网关还是子设备
【提交人】huang.zhenling
parent
e1d805f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
11 deletions
+31
-11
midware/midware/midware.c
midware/midware/midware.c
+31
-11
No files found.
midware/midware/midware.c
View file @
0d796981
...
@@ -156,21 +156,40 @@ void kk_platMsg_handle(void* data, char* chalMark){
...
@@ -156,21 +156,40 @@ void kk_platMsg_handle(void* data, char* chalMark){
else
{
else
{
info
=
cJSON_GetObjectItem
(
json
,
"info"
);
info
=
cJSON_GetObjectItem
(
json
,
"info"
);
payload
=
cJSON_GetObjectItem
(
json
,
"payload"
);
payload
=
cJSON_GetObjectItem
(
json
,
"payload"
);
if
(
info
!
=
NULL
){
if
(
info
==
NULL
||
payload
=
=
NULL
){
msgType
=
cJSON_GetObjectItem
(
info
,
"msgType
"
);
ERROR_PRINT
(
"info or payload params is error
\n
"
);
info_dcode
=
cJSON_GetObjectItem
(
info
,
"deviceCode"
)
;
goto
error
;
}
}
if
(
payload
!=
NULL
){
jsonPay
=
cJSON_GetObjectItem
(
payload
,
"params"
);
msgType
=
cJSON_GetObjectItem
(
info
,
"msgType"
);
info_dcode
=
cJSON_GetObjectItem
(
info
,
"deviceCode"
);
jsonPay
=
cJSON_GetObjectItem
(
payload
,
"params"
);
if
(
msgType
==
NULL
||
info_dcode
==
NULL
||
jsonPay
==
NULL
){
ERROR_PRINT
(
"msgType info_dcode or jsonPay params are error
\n
"
);
goto
error
;
}
}
if
(
info_dcode
!=
NULL
&&
msgType
!=
NULL
&&
strcmp
(
msgType
->
valuestring
,
"/thing/topo/add"
)
==
0
){
proCode
=
cJSON_GetObjectItem
(
jsonPay
,
"productCode"
);
if
(
strcmp
(
msgType
->
valuestring
,
"/thing/topo/add"
)
==
0
){
devCode
=
cJSON_GetObjectItem
(
jsonPay
,
"deviceCode"
);
proCode
=
cJSON_GetObjectItem
(
jsonPay
,
"productCode"
);
mac
=
cJSON_GetObjectItem
(
jsonPay
,
"mac"
);
devCode
=
cJSON_GetObjectItem
(
jsonPay
,
"deviceCode"
);
INFO_PRINT
(
"deviceCode productCode mac: [%s][%s] [%s]
\n
"
,
devCode
->
valuestring
,
proCode
->
valuestring
,
mac
->
valuestring
);
mac
=
cJSON_GetObjectItem
(
jsonPay
,
"mac"
);
if
(
proCode
==
NULL
||
devCode
==
NULL
||
mac
==
NULL
){
ERROR_PRINT
(
"productCode, deviceCode mac params are error
\n
"
);
goto
error
;
}
INFO_PRINT
(
"deviceCode productCode mac: [%s][%s] [%s]
\n
"
,
devCode
->
valuestring
,
proCode
->
valuestring
,
mac
->
valuestring
);
//判断网关还是子设备
if
(
strcmp
(
info_dcode
->
valuestring
,
devCode
->
valuestring
)
==
0
){
char
ccu_deviceCode
[
DEVICE_CODE_MAXLEN
]
=
{
0
};
HAL_GetDevice_Code
(
ccu_deviceCode
);
kk_mid_subdev_add
(
KK_DM_DEVICE_GATEWAY
,
proCode
->
valuestring
,
devCode
->
valuestring
,
mac
->
valuestring
,
ccu_deviceCode
);
}
else
{
kk_mid_subdev_add
(
KK_DM_DEVICE_SUBDEV
,
proCode
->
valuestring
,
devCode
->
valuestring
,
mac
->
valuestring
,
info_dcode
->
valuestring
);
kk_mid_subdev_add
(
KK_DM_DEVICE_SUBDEV
,
proCode
->
valuestring
,
devCode
->
valuestring
,
mac
->
valuestring
,
info_dcode
->
valuestring
);
}
}
else
if
(
info_dcode
!=
NULL
&&
strstr
(
msgType
->
valuestring
,
"property/post"
)
!=
NULL
){
}
else
if
(
strstr
(
msgType
->
valuestring
,
"property/post"
)
!=
NULL
){
INFO_PRINT
(
"save property and send to cloud
\n
"
);
INFO_PRINT
(
"save property and send to cloud
\n
"
);
char
*
outstr
=
cJSON_Print
(
payload
);
char
*
outstr
=
cJSON_Print
(
payload
);
kk_tsl_property_set_by_devicecode
(
info_dcode
->
valuestring
,
outstr
,
strlen
(
outstr
)
+
1
);
kk_tsl_property_set_by_devicecode
(
info_dcode
->
valuestring
,
outstr
,
strlen
(
outstr
)
+
1
);
...
@@ -181,6 +200,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
...
@@ -181,6 +200,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
//kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL);
//kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL);
}
}
error:
cJSON_Delete
(
json
);
cJSON_Delete
(
json
);
}
}
}
}
...
...
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