Fix warning as error for V2
Change-Id: I70cfd971fda629011ba1be84fef15afea196d393
diff --git a/mbtk/libmbtk_lib_v2/mqtt/mbtk_mqtt.c b/mbtk/libmbtk_lib_v2/mqtt/mbtk_mqtt.c
index 3b78429..40bd5e5 100755
--- a/mbtk/libmbtk_lib_v2/mqtt/mbtk_mqtt.c
+++ b/mbtk/libmbtk_lib_v2/mqtt/mbtk_mqtt.c
@@ -19,6 +19,9 @@
#include "arpa/inet.h"
#include "fcntl.h"
#include "mbtk_sock2.h"
+#include "MQTTPacket/core_sha256.h"
+#include "MQTTPacket/core_sha1.h"
+
#include "mbtk_type.h"
#include "mbtk_http.h"
@@ -111,17 +114,17 @@
printf("product_secret: %s\n", product_secret);
printf("device_name: %s\n", device_name);
- int32_t res = 0, content_len = 0;
+// int32_t content_len = 0;
char content[255] = {0};
char random[15+1]={0};;
char sign[65] = {0};
- int dynamic_register_request_len = 0;
+// int dynamic_register_request_len = 0;
// char *content_fmt = "productKey=%s&deviceName=%s&random=%s&sign=%s&signMethod=%s";
- char *signMethod = MBTK_MQTT_HTTP_SIGN_METHOD_HMACSHA256;
+// char *signMethod = MBTK_MQTT_HTTP_SIGN_METHOD_HMACSHA256;
memcpy(random, "8Ygb7ULYh53B6OA", strlen("8Ygb7ULYh53B6OA"));
- char *content_src[] = { product_key, device_name, random,sign,signMethod};
+// char *content_src[] = { product_key, device_name, random,sign,signMethod};
mbtk_imqtt_http_dynreg_sign(product_key,product_secret,device_name,random,sign);
sprintf(content, "productKey=%s&deviceName=%s&random=%s&sign=%s&signMethod=%s",
@@ -145,7 +148,7 @@
{
char* ptr_start = NULL;
char* ptr_end = NULL;
- char fac[64] = {'\0'};
+// char fac[64] = {'\0'};
ptr_start = strstr(data, "deviceSecret");
if(ptr_start != NULL)
{
@@ -217,9 +220,10 @@
const mbtk_http_session_t* session = mbtk_http_session_get(http_handle, http_session);
printf("HTTP:%d,%s,%d,%s\n",session->option,session->host,session->port,session->uri);
+#if 0
char *header = "Accept: text/xml,text/javascript,text/html,application/json\r\n" \
"Content-Type: application/x-www-form-urlencoded\r\n";
-
+#endif
mbtk_http_session_head_add(http_handle, http_session, "Accept", "text/xml,text/javascript,text/html,application/json");
@@ -260,7 +264,7 @@
void mbtk_aliyun_mqtt_get_connect_para(char *password,char *cliendid,char *username, mbtk_mqtt_device_session_t *mbtk_mqtt_device_t)
{
/*********password.mqttClientId.user_name *************/
- char content[MBTK_IMQTT_PASSWORD_LEN] = {0};
+ char content[1024] = {0};
printf("mbtk_mqtt_device_t->device_name: %s\n", mbtk_mqtt_device_t->device_name);
printf("mbtk_mqtt_device_t->product_key: %s\n", mbtk_mqtt_device_t->product_key);
@@ -272,15 +276,15 @@
// snprintf((char *)cliendid,MBTK_IMQTT_CLIENT_ID_LEN,"%s|securemode=-2,authType=regnwl,random=123,signmethod=hmacsha1,instanceId=%s|",mbtk_mqtt_device_t->device_name,"iot-06z00ag5qidat54");
- snprintf((char *)cliendid,MBTK_IMQTT_CLIENT_ID_LEN,"%s|securemode=-2,authType=regnwl,random=123,signmethod=hmacsha1|",mbtk_mqtt_device_t->device_name);
- snprintf((char *)username,MBTK_IMQTT_USER_NAME_LEN,"%s&%s",mbtk_mqtt_device_t->device_name,mbtk_mqtt_device_t->product_key);
+ snprintf((char *)cliendid,sizeof(content),"%s|securemode=-2,authType=regnwl,random=123,signmethod=hmacsha1|",mbtk_mqtt_device_t->device_name);
+ snprintf((char *)username,sizeof(content),"%s&%s",mbtk_mqtt_device_t->device_name,mbtk_mqtt_device_t->product_key);
}
void mbtk_imqtt_auth_hostname(char *dest, char *product_key, int host)
{
// char *host = "&product_key.iot-as-mqtt.cn-shanghai.aliyuncs.com";
- int8_t public_instance = 1;
+// int8_t public_instance = 1;
snprintf(dest, 100, "%s.%s", product_key, mqtt_url[host]);
}
@@ -507,7 +511,7 @@
ret = -101;
goto __END;
}
- MQTTClient(&piot_mqtt->Client, piot_mqtt->network, 1000*30, piot_mqtt->mqtt_buffer, MQTT_BUF_SIZE, piot_mqtt->mqtt_read_buffer, MQTT_BUF_SIZE);
+ MQTTClient(&piot_mqtt->Client, piot_mqtt->network, 1000*30, (unsigned char*)piot_mqtt->mqtt_buffer, MQTT_BUF_SIZE, (unsigned char*)piot_mqtt->mqtt_read_buffer, MQTT_BUF_SIZE);
MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
data.MQTTVersion = piot_mqtt->mqtt_version;
@@ -549,7 +553,7 @@
ret = -101;
goto __END;
}
- MQTTClient(&piot_mqtt->Client, piot_mqtt->network, 1000, piot_mqtt->mqtt_buffer, MQTT_BUF_SIZE, piot_mqtt->mqtt_read_buffer, MQTT_BUF_SIZE);
+ MQTTClient(&piot_mqtt->Client, piot_mqtt->network, 1000, (unsigned char*)piot_mqtt->mqtt_buffer, MQTT_BUF_SIZE, (unsigned char*)piot_mqtt->mqtt_read_buffer, MQTT_BUF_SIZE);
MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
if (piot_mqtt->willFlag) {