mirror of
https://github.com/espressif/openthread.git
synced 2026-08-01 00:27:47 +00:00
Fix compiler warning and code style. (#1605)
This commit is contained in:
+12
-4
@@ -72,15 +72,17 @@ void Coap::PrintPayload(otMessage *aMessage)
|
||||
bytesPrinted += bytesToPrint;
|
||||
}
|
||||
}
|
||||
|
||||
sServer->OutputFormat("\r\n");
|
||||
}
|
||||
|
||||
void Coap::ConvertToLower(char *aString)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
while (aString[i])
|
||||
{
|
||||
aString[i] = tolower(aString[i]);
|
||||
aString[i] = (char)tolower(aString[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -104,6 +106,7 @@ ThreadError Coap::Process(otInstance *aInstance, int argc, char *argv[], Server
|
||||
sResource.mHandler = (otCoapRequestHandler) &Coap::s_HandleServerResponse;
|
||||
|
||||
VerifyOrExit(argc > 0, error = kThreadError_InvalidArgs);
|
||||
|
||||
for (unsigned int i = 0; i < sizeof(sCommands) / sizeof(sCommands[0]); i++)
|
||||
{
|
||||
if (strcmp(argv[0], sCommands[i].mName) == 0)
|
||||
@@ -124,6 +127,7 @@ ThreadError Coap::ProcessServer(int argc, char *argv[])
|
||||
VerifyOrExit(argc > 0, error = kThreadError_InvalidArgs);
|
||||
|
||||
ConvertToLower(argv[0]);
|
||||
|
||||
if (strcmp(argv[0], "start") == 0)
|
||||
{
|
||||
SuccessOrExit(error = otCoapServerStart(sInstance));
|
||||
@@ -270,6 +274,7 @@ ThreadError Coap::ProcessClient(int argc, char *argv[])
|
||||
|
||||
// CoAP-Code
|
||||
ConvertToLower(argv[0]);
|
||||
|
||||
if (strcmp(argv[0], "get") == 0)
|
||||
{
|
||||
coapCode = kCoapRequestGet;
|
||||
@@ -313,6 +318,7 @@ ThreadError Coap::ProcessClient(int argc, char *argv[])
|
||||
|
||||
// CoAP-Type
|
||||
ConvertToLower(argv[3]);
|
||||
|
||||
if ((argc > 3) && (strcmp(argv[3], "con") == 0))
|
||||
{
|
||||
coapType = kCoapTypeConfirmable;
|
||||
@@ -339,21 +345,23 @@ ThreadError Coap::ProcessClient(int argc, char *argv[])
|
||||
|
||||
if ((coapType == kCoapTypeConfirmable) || coapCode == kCoapRequestGet)
|
||||
{
|
||||
error = otCoapSendRequest(sInstance, message, &messageInfo,
|
||||
(otCoapResponseHandler) &Coap::s_HandleClientResponse, NULL);
|
||||
error = otCoapSendRequest(sInstance, message, &messageInfo,
|
||||
(otCoapResponseHandler) &Coap::s_HandleClientResponse, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
error = otCoapSendRequest(sInstance, message, &messageInfo, NULL, NULL);
|
||||
error = otCoapSendRequest(sInstance, message, &messageInfo, NULL, NULL);
|
||||
}
|
||||
|
||||
sServer->OutputFormat("Sending CoAP message: ");
|
||||
|
||||
exit:
|
||||
|
||||
if ((error != kThreadError_None) && (message != NULL))
|
||||
{
|
||||
otMessageFree(message);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user