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
7eae9e10
Commit
7eae9e10
authored
Aug 28, 2020
by
黄振令
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】mqtt的clientid使用kk_mac地址组合,保证唯一性
parent
0d6f9397
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
application/kcloud/kcloud_config.h
application/kcloud/kcloud_config.h
+1
-1
application/kcloud/mqtt_api.c
application/kcloud/mqtt_api.c
+5
-1
No files found.
application/kcloud/kcloud_config.h
View file @
7eae9e10
...
...
@@ -3,7 +3,7 @@
#define MQTT_CONF_H_
#define ADDRESS "tcp://172.25.240.31:1983"
#define CLIENTID "
1234
"
#define CLIENTID "
kk_%s
"
#define TOPIC "/sys/a1OYuSBt23u/aIqEbWno8yDdsjCX15iq/thing/service/property/set"
#define PAYLOAD "Hello cwc World!"
...
...
application/kcloud/mqtt_api.c
View file @
7eae9e10
...
...
@@ -193,7 +193,11 @@ MQTTAsync KK_MQTT_Connect(void)
MQTTAsync_connectOptions
conn_opts
=
MQTTAsync_connectOptions_initializer
;
MQTTAsync_setTraceCallback
(
mqttTraceCallback
);
opts
.
MQTTVersion
=
MQTTVERSION_3_1_1
;
if
((
rc
=
MQTTAsync_createWithOptions
(
&
s_Client
,
ADDRESS
,
CLIENTID
,
MQTTCLIENT_PERSISTENCE_NONE
,
NULL
,
&
opts
))
!=
MQTTASYNC_SUCCESS
)
char
mac
[
16
]
=
{
0
};
char
clientBuf
[
20
]
=
{
0
};
HAL_Get_mac
(
mac
);
sprintf
(
clientBuf
,
CLIENTID
,
mac
);
if
((
rc
=
MQTTAsync_createWithOptions
(
&
s_Client
,
ADDRESS
,
clientBuf
,
MQTTCLIENT_PERSISTENCE_NONE
,
NULL
,
&
opts
))
!=
MQTTASYNC_SUCCESS
)
{
ERROR_PRINT
(
"Failed to create client object, return code %d
\n
"
,
rc
);
return
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