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
38361eed
Commit
38361eed
authored
Mar 25, 2021
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】修改OTA主题的订阅
【提交内容】陈伟灿
parent
f8e966d5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
17 deletions
+18
-17
application/kcloud/kcloud_config.h
application/kcloud/kcloud_config.h
+1
-1
application/kcloud/kcloud_data_handle.c
application/kcloud/kcloud_data_handle.c
+2
-2
application/kcloud/kk_info_report.c
application/kcloud/kk_info_report.c
+3
-3
application/kcloud/kk_register.c
application/kcloud/kk_register.c
+8
-7
application/kcloud/kk_topic_mng.c
application/kcloud/kk_topic_mng.c
+3
-3
application/kcloud/mqtt_api.c
application/kcloud/mqtt_api.c
+1
-1
No files found.
application/kcloud/kcloud_config.h
View file @
38361eed
...
...
@@ -2,7 +2,7 @@
#ifndef MQTT_CONF_H_
#define MQTT_CONF_H_
#define ADDRESS "tcp://172.25.240.
199:1883"//"tcp://172.25.240.31:1983"//
//
#define ADDRESS "tcp://172.25.240.
31:1983"//"tcp://172.25.240.199:1883"
//
#define CLIENTID "CCU.%s.%s"
#define PAYLOAD "Hello World!"
...
...
application/kcloud/kcloud_data_handle.c
View file @
38361eed
...
...
@@ -431,12 +431,12 @@ static char * _kk_data_create(const char *topic,const char *data)
char
deviceCode
[
DEVICE_CODE_LEN
]
=
{
0
};
char
*
msgStr
=
NULL
;
res
=
_kk_topic_parse_pkdn
((
char
*
)
topic
,
3
,
productCode
,
deviceCode
);
res
=
_kk_topic_parse_pkdn
((
char
*
)
topic
,
2
,
productCode
,
deviceCode
);
//if(!strcmp("gateway_2",productCode)){
//memset(productCode,0x0,sizeof(productCode));
//memcpy(productCode,"2",strlen("2"));
//}
res
|=
_kk_topic_parse_msgType
((
char
*
)
topic
,
5
,
&
msgStr
);
res
|=
_kk_topic_parse_msgType
((
char
*
)
topic
,
4
,
&
msgStr
);
infoStr_len
=
strlen
(
DM_MSG_TO_MIDDWARE
)
+
strlen
(
productCode
)
+
strlen
(
deviceCode
)
+
strlen
(
msgStr
)
+
10
;
infoStr
=
malloc
(
infoStr_len
);
if
(
infoStr
==
NULL
){
...
...
application/kcloud/kk_info_report.c
View file @
38361eed
...
...
@@ -99,7 +99,7 @@ static int kk_info_get(char *str)
}
}
str_tmp
=
cJSON_PrintUnformatted
(
root
);
INFO_PRINT
(
"JSON %s
\r\n
"
,
str_tmp
);
//
INFO_PRINT("JSON %s\r\n", str_tmp);
strcpy
(
str
,
str_tmp
);
free
(
str_tmp
);
cJSON_Delete
(
root
);
...
...
@@ -124,10 +124,10 @@ void *kk_info_nanomsg_send(void *data)
memset
(
str
,
0x0
,
sizeof
(
str
));
ret
=
kk_info_get
(
str
);
if
(
ret
==
0
){
printf
(
"*********nn_send***********
\n
"
);
//
printf("*********nn_send***********\n");
ret
=
nn_send
(
socketfd
,
str
,
strlen
(
str
),
1
);
if
(
ret
<
0
)
{
WARNING_PRINT
(
"[%s][%d]nn_send fail!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
//
WARNING_PRINT("[%s][%d]nn_send fail!!!\n",__FUNCTION__,__LINE__);
}
}
sleep
(
10
);
...
...
application/kcloud/kk_register.c
View file @
38361eed
...
...
@@ -353,7 +353,6 @@ int kk_start_ccu_register(void)
return
-
1
;
}
printf
(
"
\n
get %s
\n
"
,
buf
);
char
*
json
=
strstr
(
buf
,
"
\r\n\r\n
"
);
if
(
registerType
==
1
){
//get deviceSecret
char
*
deviceSecret
=
strstr
(
buf
,
"deviceSecret"
);
if
(
deviceSecret
!=
NULL
){
...
...
@@ -379,6 +378,7 @@ int kk_start_ccu_register(void)
if
(
jwt
!=
NULL
){
char
*
start
=
strchr
(
buf
,
'{'
);
char
*
end
=
strrchr
(
buf
,
'}'
);
if
(
start
!=
NULL
&&
end
!=
NULL
){
strncpy
(
buf2
,
start
,
end
-
start
+
1
);
ret
=
kk_parse_token
(
buf2
);
if
(
ret
==
0
){
...
...
@@ -389,6 +389,7 @@ int kk_start_ccu_register(void)
}
}
}
}
close
(
sockfd
);
return
-
1
;
}
\ No newline at end of file
application/kcloud/kk_topic_mng.c
View file @
38361eed
...
...
@@ -12,7 +12,7 @@ const char KK_URI_SYS_PREFIX[] = "biz/kk/%s/%s/thing/service/property/set";
const
char
KK_URI_SYS_PREFIX_SERVICE
[]
=
"biz/kk/%s/%s/thing/service/+"
;
const
char
KK_URI_SYS_PREFIX_TOPO_CHANGE
[]
=
"biz/kk/%s/%s/thing/topo/change"
;
const
char
KK_URI_SYS_PREFIX_EX
[]
=
"biz/kk/%s/%s"
;
const
char
KK_URI_OTA_PREFIX
[]
=
"
/ota/device/upgrade/kk/%s/%s/#
"
;
const
char
KK_URI_OTA_PREFIX
[]
=
"
ota/device/%s/%s/upgrade
"
;
const
char
KK_URI_OTA_PROCESS
[]
=
"/ota/device/progress/%s/%s"
;
const
char
KK_URI_OTA_INFORM
[]
=
"/ota/device/inform/%s/%s"
;
...
...
@@ -54,8 +54,8 @@ int KK_Subdev_Subscribe(const cJSON *root)
memset
(
url
,
0
,
url_len
);
snprintf
(
url
,
url_len
,
KK_URI_OTA_PREFIX
,
productCode
->
valuestring
,
deviceCode
->
valuestring
);
//
INFO_PRINT("ota [%s][%d] URL:%s\n",__FUNCTION__,__LINE__,url);
//
res = KK_MQTT_SubTopic(url);
INFO_PRINT
(
"ota [%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
->
valuestring
,
deviceCode
->
valuestring
);
...
...
application/kcloud/mqtt_api.c
View file @
38361eed
...
...
@@ -208,7 +208,7 @@ MQTTAsync KK_MQTT_Connect(void)
fclose
(
fp
);
}
HAL_Get_mac
(
mac
);
sprintf
(
usrname
,
"%s
&
%s"
,
KK_CCU_ID
,
KK_CCU_PRODUCTID
);
sprintf
(
usrname
,
"%s
.
%s"
,
KK_CCU_ID
,
KK_CCU_PRODUCTID
);
printf
(
"cliendid:%s,usrname:%s
\n
"
,
g_clientId
,
usrname
);
printf
(
"------------>token:%s
\n
"
,
token
);
if
((
rc
=
MQTTAsync_createWithOptions
(
&
s_Client
,
ADDRESS
,
g_clientId
,
MQTTCLIENT_PERSISTENCE_NONE
,
NULL
,
&
opts
))
!=
MQTTASYNC_SUCCESS
)
...
...
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