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
a0159423
Commit
a0159423
authored
Jul 31, 2021
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cwc' into 'master'
【修改内容】epNum适配 See merge request chenweican/k-sdk!92
parents
b4755898
f6d14e16
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
65 deletions
+82
-65
application/kcloud/kcloud_data_handle.c
application/kcloud/kcloud_data_handle.c
+20
-16
application/kcloud/kcloud_main.c
application/kcloud/kcloud_main.c
+1
-1
application/kcloud/kk_info_report.c
application/kcloud/kk_info_report.c
+19
-9
application/kcloud/kk_topic_mng.c
application/kcloud/kk_topic_mng.c
+7
-4
application/oled/main.c
application/oled/main.c
+35
-35
No files found.
application/kcloud/kcloud_data_handle.c
View file @
a0159423
...
...
@@ -52,7 +52,7 @@ const char DM_MSG_TO_MIDDWARE[] = "{\"msgtype\":\"%s\",\"productCode\":\"%s\",\"
#define KK_POWER_SWITCH_2 "PowerSwitch_2"
#define KK_POWER_SWITCH_3 "PowerSwitch_3"
#define KK_POWER_SWITCH_4 "PowerSwitch_4"
extern
char
*
KK_Make_Topic
(
cJSON
*
info
);
extern
char
*
KK_Make_Topic
(
cJSON
*
info
,
cJSON
*
data
);
extern
int
KK_Subdev_UnSubscribe
(
cJSON
*
payload
);
extern
int
KK_Subdev_UnSubscribe_By_DeviceCode
(
const
char
*
deviceCode
,
const
char
*
productCode
);
extern
int
KK_Subdev_Subscribe
(
const
cJSON
*
root
);
...
...
@@ -214,15 +214,16 @@ int _kk_sendto_cloud(cJSON *root)
if
(
msgTypeStr
==
NULL
){
return
RETURN_FAIL
;
}
topic
=
KK_Make_Topic
(
info
);
if
(
topic
==
NULL
){
return
RETURN_FAIL
;
}
pData
=
cJSON_GetObjectItem
(
root
,
MSG_PAYLOAD_STR
);
if
(
pData
==
NULL
){
free
(
topic
);
return
RETURN_FAIL
;
}
topic
=
KK_Make_Topic
(
info
,
pData
);
if
(
topic
==
NULL
){
return
RETURN_FAIL
;
}
//If topo delete,need UnSubscribe the topic
if
(
strstr
(
msgTypeStr
->
valuestring
,
KK_FILTER_DELETE_TOPIC
)
!=
NULL
){
KK_Subdev_UnSubscribe
(
pData
);
...
...
@@ -258,10 +259,12 @@ int _kk_sendto_cloud(cJSON *root)
free
(
topic
);
return
RETURN_SUCCESS
;
}
if
(
kk_check_need_split
(
info
)){
kk_split_send_data
(
pData
,
topic
);
}
else
{
//if(kk_check_need_split(info)){
//kk_split_send_data(pData,topic);
//}
//else
{
#if 0
cJSON *pParam = NULL;
cJSON *PowerSwitch = NULL;
int i = 0;
...
...
@@ -282,6 +285,7 @@ int _kk_sendto_cloud(cJSON *root)
break;
}
}
#endif
char
*
out
=
cJSON_Print
(
pData
);
KK_MQTT_SendMsg
(
topic
,(
const
char
*
)
out
);
free
(
out
);
...
...
@@ -511,7 +515,7 @@ static char * _kk_data_create(const char *topic,const char *data)
root
=
cJSON_CreateObject
();
cJSON
*
infoObj
=
cJSON_Parse
(
infoStr
);
cJSON
*
payloadObj
=
cJSON_Parse
(
data
);
#if
1
#if
0
cJSON * params = cJSON_GetObjectItem(payloadObj,"params");
if(params != NULL){
cJSON * PowerSwitch = cJSON_GetObjectItem(params,"PowerSwitch");
...
...
@@ -564,7 +568,7 @@ int KK_Send_CloudState(int state)
infoStr_len
=
strlen
(
DM_MSG_TO_MIDDWARE
)
+
strlen
(
KK_CLOUDSTATE_MSG_REPLY
)
+
10
;
infoStr
=
malloc
(
infoStr_len
);
if
(
infoStr
==
NULL
){
ERROR_PRINT
(
"
[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
ERROR_PRINT
(
"
infoStr == NULL
\n
"
);
return
RETURN_FAIL
;
}
memset
(
infoStr
,
0x0
,
infoStr_len
);
...
...
@@ -573,7 +577,7 @@ int KK_Send_CloudState(int state)
payloadStr_len
=
strlen
(
DM_MSG_CLOUDSTATE
)
+
10
;
payloadStr
=
malloc
(
payloadStr_len
);
if
(
payloadStr
==
NULL
){
ERROR_PRINT
(
"
[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
ERROR_PRINT
(
"
payloadStr == NULL
\n
"
);
return
RETURN_FAIL
;
}
memset
(
payloadStr
,
0x0
,
payloadStr_len
);
...
...
@@ -589,7 +593,7 @@ int KK_Send_CloudState(int state)
cJSON_Delete
(
root
);
free
(
payloadStr
);
free
(
infoStr
);
INFO_PRINT
(
"
[%s][%d]%s
\n
"
,
__FUNCTION__
,
__LINE__
,
out
);
INFO_PRINT
(
"
%s
\n
"
,
out
);
free
(
out
);
return
RETURN_SUCCESS
;
}
...
...
@@ -605,11 +609,11 @@ void KK_Sendto_DevData(const char *topic,const char *data)
{
if
(
_check_invalid_topic
(
topic
))
{
INFO_PRINT
(
"
[%s][%d]ingore the topic:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
topic
);
INFO_PRINT
(
"
ingore the topic:%s
\n
"
,
topic
);
return
;
//ingore the message
}
INFO_PRINT
(
"
[%s][%d]receive from cloud,topic:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
topic
);
INFO_PRINT
(
"
[%s][%d]receive from cloud,data:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
data
);
INFO_PRINT
(
"
receive from cloud,topic:%s
\n
"
,
topic
);
INFO_PRINT
(
"
receive from cloud,data:%s
\n
"
,
data
);
char
*
send_data
=
_kk_data_create
(
topic
,
data
);
if
(
send_data
==
NULL
){
return
;
...
...
application/kcloud/kcloud_main.c
View file @
a0159423
...
...
@@ -64,7 +64,7 @@ int main(int argc, char* argv[])
open
(
"kcloud"
,
LOG_PID
,
LOG_USER
);
/*set the callback to get the device date to cloud*/
kk_ipc_init
(
IPC_APP2MID
,(
ipc_cb
*
)
KK_Data_FromDev
,
NULL
,
NULL
);
//
kk_info_report_start();
kk_info_report_start
();
again:
rc
=
kk_start_ccu_register
();
if
(
rc
==
0
){
...
...
application/kcloud/kk_info_report.c
View file @
a0159423
...
...
@@ -40,10 +40,13 @@ static int kk_info_get(char *str)
int
ret
=
0
;
char
version
[
VERSION_MAXLEN
]
=
{
0
};
char
*
str_tmp
=
NULL
;
char
ccuid
[
32
]
=
{
0
};
if
(
str
==
NULL
){
return
-
1
;
}
HAL_GetVersion
(
version
);
memcpy
(
ccuid
,
KK_CCU_ID
,
strlen
(
KK_CCU_ID
));
cJSON
*
root
=
cJSON_CreateObject
();
if
(
root
)
{
...
...
@@ -56,20 +59,25 @@ static int kk_info_get(char *str)
if
(
ccu
)
{
char
status
[
4
]
=
{
0
};
cJSON_AddItemToObject
(
args
,
"ccu"
,
ccu
);
cJSON_AddStringToObject
(
ccu
,
"id"
,
"12345"
);
cJSON_AddStringToObject
(
ccu
,
"id"
,
&
ccuid
[
4
]
);
cJSON_AddStringToObject
(
ccu
,
"version"
,
version
);
cJSON_AddStringToObject
(
ccu
,
"name"
,
"kk_new_ccu"
);
if
(
kk_get_gw_status
()
==
DEVICE_OFFLINE
){
strcpy
(
status
,
"2"
);
}
else
if
(
kk_get_cloud_status
()
==
DEVICE_OFFLINE
){
//INFO_PRINT("---222kk_get_cloud_status():%d\n",kk_get_cloud_status());
//if(kk_get_gw_status() == DEVICE_OFFLINE){
//memcpy(status,"2",strlen("2"));
//}
if
(
kk_get_cloud_status
()
==
DEVICE_OFFLINE
)
{
//cJSON_AddStringToObject(ccu, "status", "1");
strcpy
(
status
,
"1"
);
//INFO_PRINT("_-----------------------------------------------------------11\n");
memcpy
(
status
,
"1"
,
strlen
(
"1"
));
}
else
{
strcpy
(
status
,
"0"
);
//INFO_PRINT("_-----------------------------------------------------------22\n");
memcpy
(
status
,
"0"
,
strlen
(
"0"
));
}
//INFO_PRINT("------------------------------------->status :%s\n",status);
cJSON_AddStringToObject
(
ccu
,
"status"
,
status
);
}
...
...
@@ -91,8 +99,10 @@ static int kk_info_get(char *str)
cJSON
*
qr_code
=
cJSON_CreateObject
();
if
(
qr_code
)
{
char
qrcodeStr
[
256
]
=
{
0
};
sprintf
(
qrcodeStr
,
"KONKE-CCU:%s:%s:BBE3C5A5FC1FDB6CA1A386AB321D02AB"
,
KK_CCU_PRODUCTID
,
&
ccuid
[
4
]);
cJSON_AddItemToObject
(
args
,
"qr_code"
,
qr_code
);
cJSON_AddStringToObject
(
qr_code
,
"string"
,
"KONKE-CCU:15:95972:E53AC78A40C4EBD4ABFFA1009794641B"
);
cJSON_AddStringToObject
(
qr_code
,
"string"
,
qrcodeStr
);
cJSON_AddBoolToObject
(
qr_code
,
"show"
,
1
);
}
cJSON
*
service
=
cJSON_CreateObject
();
...
...
application/kcloud/kk_topic_mng.c
View file @
a0159423
...
...
@@ -83,7 +83,7 @@ static int _kk_ccu_topic_subscribe(char productCode[PRODUCT_CODE_LEN],char devic
int
res
=
0
;
int
url_len
=
0
;
url_len
=
strlen
(
KK_URI_SYS_PREFIX
_SERVICE
)
+
strlen
(
productCode
)
+
strlen
(
deviceCode
)
+
1
;
url_len
=
strlen
(
KK_URI_SYS_PREFIX
)
+
strlen
(
productCode
)
+
strlen
(
deviceCode
)
+
1
;
char
*
url
=
malloc
(
url_len
);
if
(
url
==
NULL
)
{
return
-
1
;
...
...
@@ -95,12 +95,14 @@ static int _kk_ccu_topic_subscribe(char productCode[PRODUCT_CODE_LEN],char devic
//res = KK_MQTT_SubTopic(url);
memset
(
url
,
0
,
url_len
);
snprintf
(
url
,
url_len
,
KK_URI_SYS_PREFIX_SERVICE
,
productCode
,
deviceCode
);
INFO_PRINT
(
"sys [%s][%d] URL:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
url
);
res
=
KK_MQTT_SubTopic
(
url
);
memset
(
url
,
0
,
url_len
);
snprintf
(
url
,
url_len
,
KK_URI_SYS_PREFIX
,
productCode
,
deviceCode
);
INFO_PRINT
(
"sys [%s][%d] URL:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
url
);
res
=
KK_MQTT_SubTopic
(
url
);
free
(
url
);
return
res
;
}
...
...
@@ -212,7 +214,7 @@ errorreturn:
return
-
1
;
}
char
*
KK_Make_Topic
(
cJSON
*
info
)
char
*
KK_Make_Topic
(
cJSON
*
info
,
cJSON
*
data
)
{
cJSON
*
type
,
*
product_code
,
*
device_code
;
char
*
topic
=
NULL
;
...
...
@@ -236,6 +238,7 @@ char* KK_Make_Topic(cJSON *info)
KK_CCU_TOPIC_Subscribe
();
}
if
(
!
strcmp
(
product_code
->
valuestring
,
KK_GW_PRODUCTID
)){
//printf("[%s][%d]:%s\n",__FUNCTION__,__LINE__,type->valuestring);
if
(
strstr
(
type
->
valuestring
,
"/thing/status/offline"
)
!=
NULL
){
kk_set_gw_status
(
DEVICE_OFFLINE
);
}
else
if
(
strstr
(
type
->
valuestring
,
"/thing/status/online"
)
!=
NULL
){
...
...
application/oled/main.c
View file @
a0159423
This diff is collapsed.
Click to expand it.
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