Fix warning as error for V2

Change-Id: I70cfd971fda629011ba1be84fef15afea196d393
diff --git a/mbtk/libmbtk_lib_v2/mqtt/MQTTClient.c b/mbtk/libmbtk_lib_v2/mqtt/MQTTClient.c
index 4a349a7..b197a85 100755
--- a/mbtk/libmbtk_lib_v2/mqtt/MQTTClient.c
+++ b/mbtk/libmbtk_lib_v2/mqtt/MQTTClient.c
@@ -79,7 +79,7 @@
 
 void mbtk_ali_auth_regnwl_sava(MQTTMessage msg)
 {
-    printf("pub, payload: %d,%s\n", msg.payloadlen, msg.payload);
+    printf("pub, payload: %d,%s\n", msg.payloadlen, (char*)msg.payload);
     int32_t res = SUCCESS;
 
     char *client_key = "clientId",*deviceToken_key="deviceToken";
@@ -118,9 +118,9 @@
 
 int sendPacket(Client* c, int length, Timer* timer)
 {
-    int rc = FAILURE, 
+    int rc = FAILURE,
         sent = 0;
-    
+
     while (sent < length && !expired(timer))
     {
         rc = c->ipstack->mqttwrite(c->ipstack, &c->buf[sent], length, left_ms(timer));
@@ -131,7 +131,7 @@
     printf("rc ----%d,sent----%d,length----%d\n",rc,sent,length);
     if (sent == length)
     {
-        countdown(&c->ping_timer, c->keepAliveInterval); // record the fact that we have successfully sent the packet    
+        countdown(&c->ping_timer, c->keepAliveInterval); // record the fact that we have successfully sent the packet
         rc = SUCCESS;
     }
     else
@@ -144,7 +144,7 @@
 {
     int i;
     c->ipstack = network;
-    
+
     for (i = 0; i < MAX_MESSAGE_HANDLERS; ++i)
         c->messageHandlers[i].topicFilter = 0;
     c->command_timeout_ms = command_timeout_ms;
@@ -187,7 +187,7 @@
 }
 
 
-int readPacket(Client* c, Timer* timer) 
+int readPacket(Client* c, Timer* timer)
 {
     int rc = FAILURE;
     MQTTHeader header = {0};
@@ -223,7 +223,7 @@
     char* curf = topicFilter;
     char* curn = topicName->lenstring.data;
     char* curn_end = curn + topicName->lenstring.len;
-    
+
     while (*curf && curn < curn_end)
     {
         if (*curn == '/' && *curf != '/')
@@ -241,7 +241,7 @@
         curf++;
         curn++;
     };
-    
+
     return (curn == curn_end) && (*curf == '\0');
 }
 
@@ -266,15 +266,15 @@
             }
         }
     }
-    
-    if (rc == FAILURE && c->defaultMessageHandler != NULL) 
+
+    if (rc == FAILURE && c->defaultMessageHandler != NULL)
     {
         MessageData md;
         NewMessageData(&md, topicName, message);
         c->defaultMessageHandler(&md);
         rc = SUCCESS;
-    }   
-    
+    }
+
     return rc;
 }
 
@@ -287,7 +287,7 @@
         rc = SUCCESS;
         goto exit;
     }
-    
+
     if (expired(&c->ping_timer))
     {
         if (!c->ping_outstanding)
@@ -303,7 +303,7 @@
         }
     	else
     	{
-    	    printf("fail_count-------------\n",c->fail_count);
+    	    printf("fail_count:%d-------------\n",c->fail_count);
             ++(c->fail_count);
             if (c->fail_count >= MAX_FAIL_ALLOWED)
             {
@@ -334,7 +334,7 @@
 		rc =  DISCONNECTED;
 		goto exit;
 	}
-    
+
     switch (packet_type)
     {
         case CONNACK:
@@ -412,9 +412,9 @@
     int rc = SUCCESS;
     Timer timer;
 
-    InitTimer(&timer);    
+    InitTimer(&timer);
     countdown_ms(&timer, timeout_ms);
-    static int i = 0;
+//    static int i = 0;
     if (c->isconnected)
     		rc = keepalive(c);
     if(rc < 0)
@@ -435,10 +435,10 @@
 */
     do
     {
-            if (expired(&timer)) 
+            if (expired(&timer))
             break; // we timed out
     }
-    while ((rc = cycle(c, &timer)) != PUBLISH);  
+    while ((rc = cycle(c, &timer)) != PUBLISH);
     rc = SUCCESS;
     return rc;
 }
@@ -450,11 +450,11 @@
     int rc = FAILURE;
     do
     {
-            if (expired(timer)) 
+            if (expired(timer))
             break; // we timed out
     }
-    while ((rc = cycle(c, timer)) != packet_type &&  (rc = cycle(c, timer)) != DISCONNECTED);  
-    
+    while ((rc = cycle(c, timer)) != packet_type &&  (rc = cycle(c, timer)) != DISCONNECTED);
+
     return rc;
 }
 
@@ -473,7 +473,7 @@
 
     if (options == 0)
         options = &default_options; // set default options if none were supplied
-    
+
     c->keepAliveInterval = options->keepAliveInterval;
     countdown(&c->ping_timer, c->keepAliveInterval);
     printf("[%s]c->keepAliveInterval = %d", __FUNCTION__,c->keepAliveInterval);
@@ -481,7 +481,7 @@
         goto exit;
     if ((rc = sendPacket(c, len, &connect_timer)) != SUCCESS)  // send the connect packet
         goto exit; // there was a problem
-    
+
     // this will be a blocking call, wait for the connack
     if (waitfor(c, CONNACK, &connect_timer) == CONNACK)
     {
@@ -494,7 +494,7 @@
     }
     else
         rc = FAILURE;
-    
+
 exit:
     if (rc == SUCCESS)
         c->isconnected = 1;
@@ -503,31 +503,31 @@
 
 
 int MQTTSubscribe(Client* c, const char* topicFilter, enum QoS qos, messageHandler messageHandler)
-{ 
-    int rc = FAILURE;  
+{
+    int rc = FAILURE;
     Timer timer;
     int len = 0;
     MQTTString topic = MQTTString_initializer;
     topic.cstring = (char *)topicFilter;
-    
+
     InitTimer(&timer);
     countdown_ms(&timer, c->command_timeout_ms);
 
     if (!c->isconnected)
         goto exit;
-    
+
     len = MQTTSerialize_subscribe(c->buf, c->buf_size, 0, getNextPacketId(c), 1, &topic, (int*)&qos);
     if (len <= 0)
         goto exit;
     if ((rc = sendPacket(c, len, &timer)) != SUCCESS) // send the subscribe packet
         goto exit;             // there was a problem
-    
-    if (waitfor(c, SUBACK, &timer) == SUBACK)      // wait for suback 
+
+    if (waitfor(c, SUBACK, &timer) == SUBACK)      // wait for suback
     {
         int count = 0, grantedQoS = -1;
         unsigned short mypacketid;
         if (MQTTDeserialize_suback(&mypacketid, 1, &count, &grantedQoS, c->readbuf, c->readbuf_size) == 1)
-            rc = grantedQoS; // 0, 1, 2 or 0x80 
+            rc = grantedQoS; // 0, 1, 2 or 0x80
         if (rc != 0x80)
         {
             int i;
@@ -543,9 +543,9 @@
             }
         }
     }
-    else 
+    else
         rc = FAILURE;
-        
+
 exit:
     return rc;
 }
@@ -565,16 +565,16 @@
 }
 
 int MQTTUnsubscribe(Client* c, const char* topicFilter)
-{   
+{
     int rc = FAILURE;
-    Timer timer;    
+    Timer timer;
     MQTTString topic = MQTTString_initializer;
     topic.cstring = (char *)topicFilter;
     int len = 0;
 
     InitTimer(&timer);
     countdown_ms(&timer, c->command_timeout_ms);
-    
+
     if (!c->isconnected)
         goto exit;
     if(messageHandlersFindIndex(c,topicFilter) < 0)
@@ -598,14 +598,14 @@
                 && (strcmp(c->messageHandlers[i].topicFilter, topicFilter) == 0))
                 {
                     c->messageHandlers[i].topicFilter=NULL;
-                    rc = 0; 
+                    rc = 0;
                 }
             }
         }
     }
     else
         rc = FAILURE;
-    
+
 exit:
     return rc;
 }
@@ -614,20 +614,20 @@
 int MQTTPublish(Client* c, const char* topicName, MQTTMessage* message)
 {
     int rc = FAILURE;
-    Timer timer;   
+    Timer timer;
     MQTTString topic = MQTTString_initializer;
     topic.cstring = (char *)topicName;
     int len = 0;
 
     InitTimer(&timer);
     countdown_ms(&timer, c->command_timeout_ms);
-    
+
     if (!c->isconnected)
         goto exit;
     if (message->qos == QOS1 || message->qos == QOS2)
         message->id = getNextPacketId(c);
-    
-    len = MQTTSerialize_publish(c->buf, c->buf_size, 0, message->qos, message->retained, message->id, 
+
+    len = MQTTSerialize_publish(c->buf, c->buf_size, 0, message->qos, message->retained, message->id,
               topic, (unsigned char*)message->payload, message->payloadlen);
 
     if (len <= 0)
@@ -659,14 +659,14 @@
         else
             rc = FAILURE;
     }
-    
+
 exit:
     return rc;
 }
 
 
 int MQTTDisconnect(Client* c ,Network * n)
-{  
+{
     int rc = FAILURE;
     Timer timer;     // we might wait for incomplete incoming publishes to complete
     int len = MQTTSerialize_disconnect(c->buf, c->buf_size);
@@ -676,7 +676,7 @@
 
     if (len > 0)
         rc = sendPacket(c, len, &timer);            // send the disconnect packet
-        
+
     c->isconnected = 0;
     n->disconnect(n);
     return rc;