Merge pull request #40 from ucloud/bugfix_sample_topic

bugfix sample topic
This commit is contained in:
杜敏敏 2021-01-22 15:05:18 +08:00 committed by GitHub
commit 54229023a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -42,7 +42,7 @@ static int _publish_msg(void *client)
{
char topicName[128] = {0};
int num = 18;
HAL_Snprintf(topicName, 128, "/%s/%s/upload/event", PKG_USING_UCLOUD_IOT_SDK_PRODUCT_SN, PKG_USING_UCLOUD_IOT_SDK_DEVICE_SN);
HAL_Snprintf(topicName, 128, "/%s/%s/upload", PKG_USING_UCLOUD_IOT_SDK_PRODUCT_SN, PKG_USING_UCLOUD_IOT_SDK_DEVICE_SN);
PublishParams pub_params = DEFAULT_PUB_PARAMS;
@ -59,7 +59,7 @@ static int _publish_msg(void *client)
static int _register_subscribe_topics(void *client)
{
static char topic_name[128] = {0};
HAL_Snprintf(topic_name, 128, "/%s/%s/upload/event", PKG_USING_UCLOUD_IOT_SDK_PRODUCT_SN, PKG_USING_UCLOUD_IOT_SDK_DEVICE_SN);
HAL_Snprintf(topic_name, 128, "/%s/%s/set", PKG_USING_UCLOUD_IOT_SDK_PRODUCT_SN, PKG_USING_UCLOUD_IOT_SDK_DEVICE_SN);
SubscribeParams sub_params = DEFAULT_SUB_PARAMS;
sub_params.on_message_handler = on_message_callback;

View File

@ -144,7 +144,7 @@ static int _setup_connect_init_params(MQTTInitParams* initParams)
static int _publish_msg(void *client)
{
char topicName[128] = {0};
HAL_Snprintf(topicName, 128, "/%s/%s/upload/event", PKG_USING_UCLOUD_IOT_SDK_PRODUCT_SN, PKG_USING_UCLOUD_IOT_SDK_DEVICE_SN);
HAL_Snprintf(topicName, 128, "/%s/%s/upload", PKG_USING_UCLOUD_IOT_SDK_PRODUCT_SN, PKG_USING_UCLOUD_IOT_SDK_DEVICE_SN);
PublishParams pub_params = DEFAULT_PUB_PARAMS;
pub_params.qos = QOS1;
@ -171,7 +171,7 @@ static int _publish_msg(void *client)
static int _register_subscribe_topics(void *client)
{
static char topic_name[128] = {0};
int size = HAL_Snprintf(topic_name, sizeof(topic_name), "/%s/%s/upload/event", PKG_USING_UCLOUD_IOT_SDK_PRODUCT_SN, PKG_USING_UCLOUD_IOT_SDK_DEVICE_SN);
int size = HAL_Snprintf(topic_name, sizeof(topic_name), "/%s/%s/set", PKG_USING_UCLOUD_IOT_SDK_PRODUCT_SN, PKG_USING_UCLOUD_IOT_SDK_DEVICE_SN);
if (size < 0 || size > sizeof(topic_name) - 1)
{
HAL_Printf("topic content length not enough! content size:%d buf size:%d\n", size, (int)sizeof(topic_name));