Fix code warning.
Change-Id: Ib11fb49f528d3688351ae349d5b4e307c28b3967
diff --git a/mbtk/libmbtk_lib/coap/mbtk_coap.c b/mbtk/libmbtk_lib/coap/mbtk_coap.c
index 226fd5c..2fd96a8 100755
--- a/mbtk/libmbtk_lib/coap/mbtk_coap.c
+++ b/mbtk/libmbtk_lib/coap/mbtk_coap.c
@@ -59,26 +59,29 @@
static mbtk_ecoap_state_e mbtk_ecoap_state = MBTK_ECOAP_STATE_NON;
//static uint16 mbtk_ecoap_curr_coap_id = 0;
-static char mbtk_ecoap_host[MBTK_ECOAP_NEW_MAX+1] = {'\0'};
+//static char mbtk_ecoap_host[MBTK_ECOAP_NEW_MAX+1] = {'\0'};
-static int mbtk_ecoap_port;
-static int mbtk_ecoap_is_dtls;
+//static int mbtk_ecoap_port;
+//static int mbtk_ecoap_is_dtls;
static mbtk_ecoap_opt_2 mbtk_ecoap_option_2;
static mbtk_ecoap_opt_3 mbtk_ecoap_option_3;
static int mbtk_ecoap_recv = -1;
-static int mbtk_ecoap_cur_time =0;
+//static int mbtk_ecoap_cur_time =0;
/*func------------------------*/
void mbtk_ecoap_option_add(mbtk_ecoap_option_s *option);
int mbtk_ecoap_list_del(uint16 message_id,int optDel);
-
+int mbtk_ecoap_get_message_type(void);
+void mbtk_ecoap_get_code(char *ptr);
#define HEXCHAR(x) ((x >= '0' && x <= '9') || (x >= 'a' && x <= 'f') || (x >= 'A' && x <= 'F'))
#if 1
+#ifndef toupper
#define toupper(a) ((((a) >= 'a') && ((a) <= 'z')) ? ((a) - 'a' + 'A') : (a))
+#endif
void HexToStr(byte *pbDest, byte *pbSrc, int nLen)
{
@@ -339,7 +342,7 @@
}
}
-
+#if 0
static int
mbtk_ecoap_is_open()
{
@@ -400,7 +403,7 @@
{
}
-
+#endif
@@ -638,7 +641,7 @@
break;
}
default:
- printf("No such type:%s\n",option->type);
+ printf("No such type:%d\n",option->type);
break;
}
}
@@ -731,7 +734,7 @@
break;
}
default:
- printf("No such type:%s\n",type);
+ printf("No such type:%d\n",type);
break;
}
}
@@ -919,8 +922,6 @@
type,
code,
mesageId);
-
- return 0;
}
@@ -947,8 +948,8 @@
memcpy(token,coapGetRecvTokenPointer(),token_len);
LOGE("token[%d]:%s\n",token_len,token);
- uint16 playload_len = coapGetRecvPayloadLength();
- uint8 *playload = coapGetRecvPayloadPointer();
+// uint16 playload_len = coapGetRecvPayloadLength();
+// uint8 *playload = coapGetRecvPayloadPointer();
// printf("----------------payload-----------------\n");
// coap_log(0,(char*)playload,playload_len);
// printf("--------------payload end----------------\n");
@@ -974,7 +975,7 @@
mbtk_ecoap_package_s * coap_send = mbtk_ecoap_get_by_msg_id(message_id);
if(coap_send != NULL)
{
- int number;
+ uint32_t number;
uint8_t more_flag;
uint8_t size;
LOGE("Get message(%d) ack.\n",message_id);
@@ -1055,7 +1056,7 @@
}
-static int mbtk_ecoap_open(int open);
+//static int mbtk_ecoap_open(int open);
@@ -1098,7 +1099,7 @@
)
{
int result = 0;
- int rx_mod = mode;
+// int rx_mod = mode;
return result;
}
@@ -1109,7 +1110,7 @@
)
{
int result = 0;
- uint16 ecoappr = format;
+// uint16 ecoappr = format;
return result;
}
@@ -1119,7 +1120,7 @@
)
{
int result = 0;
- int get_len = len;
+// int get_len = len;
return result;
diff --git a/mbtk/libmbtk_lib/coap/mbtk_coap_api.cpp b/mbtk/libmbtk_lib/coap/mbtk_coap_api.cpp
index 0a6dc19..c864fe0 100755
--- a/mbtk/libmbtk_lib/coap/mbtk_coap_api.cpp
+++ b/mbtk/libmbtk_lib/coap/mbtk_coap_api.cpp
@@ -280,7 +280,7 @@
strcpy(type, "Reset");
break;
}
- char code[30];
+ char code[40];
switch(g_CoapRecvPointer->getCode())
{
case COAP_EMPTY:
@@ -383,28 +383,28 @@
uint8_t *tokenPointer = g_CoapRecvPointer->getPDUPointer()+COAP_HDR_SIZE;
if(tokenLength==0)
{
- sprintf(outBuffer,"%sNo token\r\n",outBuffer);
+ sprintf(outBuffer + strlen(outBuffer),"No token\r\n");
}
else
{
- sprintf(outBuffer,"%sToken of %d bytes.\r\n"
+ sprintf(outBuffer + strlen(outBuffer),"Token of %d bytes.\r\n"
"Value: %s\r\n",
- outBuffer,tokenLength, (char*)tokenPointer);
+ tokenLength, (char*)tokenPointer);
for(int j=0; j<tokenLength; j++)
{
- sprintf(outBuffer,"%s%.2x",outBuffer, tokenPointer[j]);
+ sprintf(outBuffer + strlen(outBuffer),"%.2x", tokenPointer[j]);
}
}
// print options
CoapPDU::CoapOption* options = g_CoapRecvPointer->getOptions();
if(options==NULL)
{
- sprintf(outBuffer,"\r\n%sNO options\r\n", outBuffer);
+ sprintf(outBuffer + strlen(outBuffer),"\r\nNO options\r\n");
}
for(int i=0; i<g_CoapRecvPointer->getNumOptions(); i++)
{
- char optionNumberBuffer[20];
+ char optionNumberBuffer[40];
switch(options[i].optionNumber)
{
case COAP_OPTION_IF_MATCH:
@@ -479,12 +479,11 @@
}
}
sprintf(optionValue,"%s\"\r\n",optionValue);*/
- sprintf(outBuffer,"\r\n%sOPTION (%d/%d)\r\n"
+ sprintf(outBuffer + strlen(outBuffer),"\r\nOPTION (%d/%d)\r\n"
"Option number (delta): %hu (%hu)\r\n"
"Name: %s\r\n"
"Value length: %u\r\n"
"Value: \"%s",
- outBuffer,
i + 1,g_CoapRecvPointer->getNumOptions(),
options[i].optionNumber,options[i].optionDelta,
optionNumberBuffer,
@@ -497,12 +496,12 @@
// print payload
if(g_CoapRecvPointer->getPayloadLength() == 0)
{
- sprintf(outBuffer,"%sNo payload\r\n", outBuffer);
+ sprintf(outBuffer + strlen(outBuffer),"No payload\r\n");
}
else
{
- sprintf(outBuffer, "%sPayload of %d bytes\r\n"
- "Value: \"%s\"\r\n", outBuffer,
+ sprintf(outBuffer + strlen(outBuffer), "Payload of %d bytes\r\n"
+ "Value: \"%s\"\r\n",
g_CoapRecvPointer->getPayloadLength(),
(char *)g_CoapRecvPointer->getPayloadPointer());
/*sprintf(outBuffer,"%sPayload of %d bytes\r\n", outBuffer,g_CoapRecvPointer->getPayloadLength());
@@ -867,12 +866,12 @@
else
{
uint8_t* payloadPointer = g_CoapRecvPointer->getPayloadPointer();
- sprintf(out,"%s:%d\r\n",out, payloadLength*2);
+ sprintf(out + strlen(out),":%d\r\n",payloadLength*2);
for(int j=0; j<payloadLength; j++)
{
- sprintf(out,"%s%.2X",out,payloadPointer[j]);
+ sprintf(out + strlen(out),"%.2X", payloadPointer[j]);
}
- sprintf(out,"%s\r\n",out);
+ sprintf(out + strlen(out),"\r\n");
return 1;
}
}