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
3cb8ced4
Commit
3cb8ced4
authored
Aug 06, 2020
by
黄振令
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改要点】冲突解决
【提交人】黄振令
parent
b951d6a6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
5 deletions
+40
-5
application/kcloud/kcloud_config.h
application/kcloud/kcloud_config.h
+1
-1
application/kcloud/kcloud_main.c
application/kcloud/kcloud_main.c
+1
-1
application/kcloud/kk_topic_mng.c
application/kcloud/kk_topic_mng.c
+37
-2
application/kcloud/mqtt_api.h
application/kcloud/mqtt_api.h
+1
-1
No files found.
application/kcloud/kcloud_config.h
View file @
3cb8ced4
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#define ADDRESS "tcp://172.25.240.31:1983"
#define ADDRESS "tcp://172.25.240.31:1983"
#define CLIENTID "1234"
#define CLIENTID "1234"
#define TOPIC "/sys/a1OYuSBt23u/aIqEbWno8yDdsjCX15iq/
#
"
#define TOPIC "/sys/a1OYuSBt23u/aIqEbWno8yDdsjCX15iq/
thing/service/property/set
"
#define PAYLOAD "Hello cwc World!"
#define PAYLOAD "Hello cwc World!"
#define QOS 2
#define QOS 2
...
...
application/kcloud/kcloud_main.c
View file @
3cb8ced4
...
@@ -67,7 +67,7 @@ int main(int argc, char* argv[])
...
@@ -67,7 +67,7 @@ int main(int argc, char* argv[])
/*set the callback to get the device date to cloud*/
/*set the callback to get the device date to cloud*/
HAL_SetProduct_Type
(
PRODUCT_TPYE
);
HAL_SetProduct_Type
(
PRODUCT_TPYE
);
HAL_SetProduct_Code
(
PRODUCT_CODE
);
HAL_SetProduct_Code
(
PRODUCT_CODE
);
kk_ipc_init
(
IPC_APP2MID
,
KK_
Sendto_CloudData
);
kk_ipc_init
(
IPC_APP2MID
,
KK_
Data_FromDev
);
rc
=
mqtt_start
();
rc
=
mqtt_start
();
return
rc
;
return
rc
;
...
...
application/kcloud/kk_topic_mng.c
View file @
3cb8ced4
...
@@ -3,11 +3,46 @@
...
@@ -3,11 +3,46 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include "kk_product.h"
#include "kk_product.h"
#include "cJSON.h"
const
char
KK_URI_SYS_PREFIX
[]
=
"/sys/%s/%s/#"
;
const
char
KK_URI_SYS_PREFIX
[]
=
"/sys/%s/%s/#"
;
int
KK_Subdev_Subscribe
(
const
cJSON
*
root
)
{
int
res
=
0
;
cJSON
*
productType
=
NULL
;
cJSON
*
productCode
=
NULL
;
cJSON
*
data
=
NULL
;
cJSON
*
cmd
=
NULL
;
int
url_len
=
0
;
data
=
cJSON_GetObjectItem
(
root
,
"data"
);
if
(
data
==
NULL
){
return
-
1
;
}
productType
=
cJSON_GetObjectItem
(
data
,
"productType"
);
if
(
productType
==
NULL
){
return
-
1
;
}
productCode
=
cJSON_GetObjectItem
(
data
,
"productCode"
);
if
(
productCode
==
NULL
){
return
-
1
;
}
url_len
=
strlen
(
KK_URI_SYS_PREFIX
)
+
strlen
(
productType
->
valuestring
)
+
strlen
(
productCode
->
valuestring
)
+
1
;
char
*
url
=
malloc
(
url_len
);
if
(
url
==
NULL
)
{
return
-
1
;
}
memset
(
url
,
0
,
url_len
);
snprintf
(
url
,
url_len
,
KK_URI_SYS_PREFIX
,
productType
->
valuestring
,
productCode
->
valuestring
);
printf
(
"[%s][%d] URL:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
url
);
res
=
KK_MQTT_SubTopic
(
url
);
free
(
url
);
return
res
;
}
int
_kk_client_subscribe
(
char
productType
[
PRODUCT_TYPE_LEN
],
char
productCode
[
PRODUCT_CODE_LEN
])
static
int
_kk_client_subscribe
(
char
productType
[
PRODUCT_TYPE_LEN
],
char
productCode
[
PRODUCT_CODE_LEN
])
{
{
int
res
=
0
,
index
=
0
,
fail_count
=
0
;
int
res
=
0
,
index
=
0
,
fail_count
=
0
;
...
@@ -26,7 +61,7 @@ int _kk_client_subscribe(char productType[PRODUCT_TYPE_LEN], char productCode[PR
...
@@ -26,7 +61,7 @@ int _kk_client_subscribe(char productType[PRODUCT_TYPE_LEN], char productCode[PR
res
=
KK_MQTT_SubTopic
(
url
);
res
=
KK_MQTT_SubTopic
(
url
);
free
(
url
);
free
(
url
);
return
0
;
return
res
;
}
}
int
KK_Client_Gateway_Subscribe
(
void
)
int
KK_Client_Gateway_Subscribe
(
void
)
...
...
application/kcloud/mqtt_api.h
View file @
3cb8ced4
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#include "kcloud_log.h"
#include "kcloud_log.h"
#include "kcloud_config.h"
#include "kcloud_config.h"
extern
void
KK_
Sendto_CloudData
(
void
*
data
,
int
len
);
extern
void
KK_
Data_FromDev
(
void
*
str
,
int
len
);
extern
int
KK_MQTT_SubTopic
(
char
*
topicName
);
extern
int
KK_MQTT_SubTopic
(
char
*
topicName
);
...
...
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