Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lw/logging improvements #782

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions coap/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ lwm2m_transaction_t * transaction_new(void * sessionH,
lwm2m_transaction_t * transacP;
int result;

LOG_ARG("method: %d, altPath: \"%s\", mID: %d, token_len: %d",
method, STR_NULL2EMPTY(altPath), mID, token_len);
LOG_URI(uriP);
LOG_ARG_DBG("method: %d, altPath: \"%s\", mID: %d, token_len: %d", method, STR_NULL2EMPTY(altPath), mID, token_len);
LOG_ARG_DBG("%s", LOG_URI_TO_STRING(uriP));

// no transactions without peer
if (NULL == sessionH) return NULL;
Expand Down Expand Up @@ -239,11 +238,11 @@ lwm2m_transaction_t * transaction_new(void * sessionH,
}
}

LOG_ARG("Exiting on success. new transac=%p", (void *)transacP);
LOG_ARG_DBG("Exiting on success. new transac=%p", (void *)transacP);
return transacP;

error:
LOG("Exiting on failure");
LOG_DBG("Exiting on failure");
if(transacP->message)
{
coap_free_header(transacP->message);
Expand All @@ -255,7 +254,7 @@ lwm2m_transaction_t * transaction_new(void * sessionH,

void transaction_free(lwm2m_transaction_t * transacP)
{
LOG_ARG("Entering. transaction=%p", (void *)transacP);
LOG_ARG_DBG("Entering. transaction=%p", (void *)transacP);
if (transacP->message)
{
coap_free_header(transacP->message);
Expand All @@ -279,7 +278,7 @@ void transaction_free(lwm2m_transaction_t * transacP)
void transaction_remove(lwm2m_context_t * contextP,
lwm2m_transaction_t * transacP)
{
LOG_ARG("Entering. transaction=%p", (void *)transacP);
LOG_ARG_DBG("Entering. transaction=%p", (void *)transacP);
contextP->transactionList = (lwm2m_transaction_t *) LWM2M_LIST_RM(contextP->transactionList, transacP->mID, NULL);
transaction_free(transacP);
}
Expand All @@ -293,7 +292,7 @@ bool transaction_handleResponse(lwm2m_context_t * contextP,
bool reset = false;
lwm2m_transaction_t * transacP;

LOG("Entering");
LOG_DBG("Entering");
transacP = contextP->transactionList;

while (NULL != transacP)
Expand Down Expand Up @@ -370,7 +369,7 @@ int transaction_send(lwm2m_context_t * contextP,
{
bool maxRetriesReached = false;

LOG_ARG("Entering: transaction=%p", (void *)transacP);
LOG_ARG_DBG("Entering: transaction=%p", (void *)transacP);
if (transacP->buffer == NULL)
{
transacP->buffer_len = coap_serialize_get_size(transacP->message);
Expand Down Expand Up @@ -444,7 +443,7 @@ int transaction_send(lwm2m_context_t * contextP,
error:
if (transacP->callback)
{
LOG_ARG("transaction %p expired..calling callback", (void *)transacP);
LOG_ARG_DBG("transaction %p expired..calling callback", (void *)transacP);
transacP->callback(contextP, transacP, NULL);
}
transaction_remove(contextP, transacP);
Expand All @@ -457,7 +456,7 @@ void transaction_step(lwm2m_context_t * contextP,
{
lwm2m_transaction_t * transacP;

LOG("Entering");
LOG_DBG("Entering");
transacP = contextP->transactionList;
while (transacP != NULL)
{
Expand Down
63 changes: 29 additions & 34 deletions core/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static void prv_handleResponse(lwm2m_server_t * bootstrapServer,
{
if (COAP_204_CHANGED == message->code)
{
LOG("Received ACK/2.04, Bootstrap pending, waiting for DEL/PUT from BS server...");
LOG_DBG("Received ACK/2.04, Bootstrap pending, waiting for DEL/PUT from BS server...");
bootstrapServer->status = STATE_BS_PENDING;
bootstrapServer->registration = lwm2m_gettime() + COAP_EXCHANGE_LIFETIME;
}
Expand All @@ -55,7 +55,7 @@ static void prv_handleBootstrapReply(lwm2m_context_t * contextP,

(void)contextP; /* unused */

LOG("Entering");
LOG_DBG("Entering");

if (bootstrapServer->status == STATE_BS_INITIATED)
{
Expand All @@ -78,7 +78,7 @@ static void prv_requestBootstrap(lwm2m_context_t * context,
int query_length = 0;
int res;

LOG("Entering");
LOG_DBG("Entering");

query_length = utils_stringCopy(query, PRV_QUERY_BUFFER_LENGTH, QUERY_STARTER QUERY_NAME);
if (query_length < 0)
Expand Down Expand Up @@ -132,7 +132,7 @@ static void prv_requestBootstrap(lwm2m_context_t * context,
{
lwm2m_transaction_t * transaction = NULL;

LOG("Bootstrap server connection opened");
LOG_DBG("Bootstrap server connection opened");

transaction = transaction_new(bootstrapServer->sessionH, COAP_POST, NULL, NULL, context->nextMID++, 4, NULL);
if (transaction == NULL)
Expand All @@ -148,13 +148,13 @@ static void prv_requestBootstrap(lwm2m_context_t * context,
context->transactionList = (lwm2m_transaction_t *)LWM2M_LIST_ADD(context->transactionList, transaction);
if (transaction_send(context, transaction) == 0)
{
LOG("CI bootstrap requested to BS server");
LOG_DBG("CI bootstrap requested to BS server");
bootstrapServer->status = STATE_BS_INITIATED;
}
}
else
{
LOG("Connecting bootstrap server failed");
LOG_DBG("Connecting bootstrap server failed");
bootstrapServer->status = STATE_BS_FAILED;
}
}
Expand Down Expand Up @@ -515,11 +515,11 @@ void bootstrap_step(lwm2m_context_t * contextP,
{
lwm2m_server_t * targetP;

LOG("entering");
LOG_DBG("entering");
targetP = contextP->bootstrapServerList;
while (targetP != NULL)
{
LOG_ARG("Initial status: %s", STR_STATUS(targetP->status));
LOG_ARG_DBG("Initial status: %s", STR_STATUS(targetP->status));
switch (targetP->status)
{
case STATE_DEREGISTERED:
Expand Down Expand Up @@ -581,7 +581,7 @@ void bootstrap_step(lwm2m_context_t * contextP,
default:
break;
}
LOG_ARG("Final status: %s", STR_STATUS(targetP->status));
LOG_ARG_DBG("Final status: %s", STR_STATUS(targetP->status));
targetP = targetP->next;
}
}
Expand All @@ -591,14 +591,14 @@ uint8_t bootstrap_handleFinish(lwm2m_context_t * context,
{
lwm2m_server_t * bootstrapServer;

LOG("Entering");
LOG_DBG("Entering");
bootstrapServer = utils_findBootstrapServer(context, fromSessionH);
if (bootstrapServer != NULL
&& bootstrapServer->status == STATE_BS_PENDING)
{
if (object_getServers(context, true) == 0)
{
LOG("Bootstrap server status changed to STATE_BS_FINISHING");
LOG_DBG("Bootstrap server status changed to STATE_BS_FINISHING");
bootstrapServer->status = STATE_BS_FINISHING;
return COAP_204_CHANGED;
}
Expand All @@ -621,7 +621,7 @@ void bootstrap_start(lwm2m_context_t * contextP)
{
lwm2m_server_t * targetP;

LOG("Entering");
LOG_DBG("Entering");
targetP = contextP->bootstrapServerList;
while (targetP != NULL)
{
Expand All @@ -644,7 +644,7 @@ lwm2m_status_t bootstrap_getStatus(lwm2m_context_t * contextP)
lwm2m_server_t * targetP;
lwm2m_status_t bs_status;

LOG("Entering");
LOG_DBG("Entering");
targetP = contextP->bootstrapServerList;
bs_status = STATE_BS_FAILED;

Expand Down Expand Up @@ -673,26 +673,21 @@ lwm2m_status_t bootstrap_getStatus(lwm2m_context_t * contextP)
targetP = targetP->next;
}

LOG_ARG("Returned status: %s", STR_STATUS(bs_status));
LOG_ARG_DBG("Returned status: %s", STR_STATUS(bs_status));

return bs_status;
}

static uint8_t prv_checkServerStatus(lwm2m_server_t * serverP)
{
LOG_ARG("Initial status: %s", STR_STATUS(serverP->status));
LOG_ARG_DBG("Initial status: %s", STR_STATUS(serverP->status));

switch (serverP->status)
{
case STATE_BS_HOLD_OFF:
case STATE_BS_INITIATED: // The ACK was probably lost
serverP->status = STATE_BS_PENDING;
LOG_ARG("Status changed to: %s", STR_STATUS(serverP->status));
break;

case STATE_BS_INITIATED:
// The ACK was probably lost
serverP->status = STATE_BS_PENDING;
LOG_ARG("Status changed to: %s", STR_STATUS(serverP->status));
LOG_ARG_DBG("Status changed to: %s", STR_STATUS(serverP->status));
break;

case STATE_DEREGISTERED:
Expand All @@ -706,7 +701,7 @@ static uint8_t prv_checkServerStatus(lwm2m_server_t * serverP)
case STATE_BS_FAILING:
case STATE_BS_FAILED:
default:
LOG("Returning COAP_IGNORE");
LOG_DBG("Returning COAP_IGNORE");
return COAP_IGNORE;
}

Expand Down Expand Up @@ -760,8 +755,8 @@ uint8_t bootstrap_handleCommand(lwm2m_context_t * contextP,
uint8_t result;
lwm2m_media_type_t format;

LOG_ARG("Code: %02X", message->code);
LOG_URI(uriP);
LOG_ARG_DBG("Code: %02X", message->code);
LOG_ARG_DBG("%s", LOG_URI_TO_STRING(uriP));
format = utils_convertMediaType(message->content_type);

result = prv_checkServerStatus(serverP);
Expand Down Expand Up @@ -966,7 +961,7 @@ uint8_t bootstrap_handleCommand(lwm2m_context_t * contextP,
contextP->state = STATE_BOOTSTRAPPING;
}
}
LOG_ARG("Server status: %s", STR_STATUS(serverP->status));
LOG_ARG_DBG("Server status: %s", STR_STATUS(serverP->status));

return result;
}
Expand All @@ -978,7 +973,7 @@ uint8_t bootstrap_handleDeleteAll(lwm2m_context_t * contextP,
uint8_t result;
lwm2m_object_t * objectP;

LOG("Entering");
LOG_DBG("Entering");
serverP = utils_findBootstrapServer(contextP, fromSessionH);
if (serverP == NULL) return COAP_IGNORE;
result = prv_checkServerStatus(serverP);
Expand Down Expand Up @@ -1043,7 +1038,7 @@ uint8_t bootstrap_handleRequest(lwm2m_context_t * contextP,
char * name;
lwm2m_media_type_t format = 0;

LOG_URI(uriP);
LOG_ARG_DBG("%s", LOG_URI_TO_STRING(uriP));
if (contextP->bootstrapCallback == NULL) return COAP_500_INTERNAL_SERVER_ERROR;
if (message->code != COAP_POST) return COAP_400_BAD_REQUEST;
if (message->uri_query == NULL) return COAP_400_BAD_REQUEST;
Expand Down Expand Up @@ -1119,7 +1114,7 @@ void lwm2m_set_bootstrap_callback(lwm2m_context_t * contextP,
lwm2m_bootstrap_callback_t callback,
void * userData)
{
LOG("Entering");
LOG_DBG("Entering");
contextP->bootstrapCallback = callback;
contextP->bootstrapUserData = userData;
}
Expand Down Expand Up @@ -1178,7 +1173,7 @@ int lwm2m_bootstrap_delete(lwm2m_context_t * contextP,
lwm2m_transaction_t * transaction;
bs_data_t * dataP;

LOG_URI(uriP);
LOG_ARG_DBG("%s", LOG_URI_TO_STRING(uriP));
transaction = transaction_new(sessionH, COAP_DELETE, NULL, uriP, contextP->nextMID++, 4, NULL);
if (transaction == NULL) return COAP_500_INTERNAL_SERVER_ERROR;

Expand Down Expand Up @@ -1217,7 +1212,7 @@ int lwm2m_bootstrap_write(lwm2m_context_t * contextP,
lwm2m_transaction_t * transaction;
bs_data_t * dataP;

LOG_URI(uriP);
LOG_ARG_DBG("%s", LOG_URI_TO_STRING(uriP));
if (uriP == NULL
|| buffer == NULL
|| length == 0)
Expand Down Expand Up @@ -1259,7 +1254,7 @@ int lwm2m_bootstrap_finish(lwm2m_context_t * contextP,
lwm2m_transaction_t * transaction;
bs_data_t * dataP;

LOG("Entering");
LOG_DBG("Entering");
transaction = transaction_new(sessionH, COAP_POST, NULL, NULL, contextP->nextMID++, 4, NULL);
if (transaction == NULL) return COAP_500_INTERNAL_SERVER_ERROR;

Expand Down Expand Up @@ -1288,7 +1283,7 @@ int lwm2m_bootstrap_discover(lwm2m_context_t * contextP, void * sessionH, lwm2m_
lwm2m_transaction_t * transaction;
bs_data_t * dataP;

LOG_URI(uriP);
LOG_ARG_DBG("%s", LOG_URI_TO_STRING(uriP));

if (uriP
&& (LWM2M_URI_IS_SET_INSTANCE(uriP)
Expand Down Expand Up @@ -1326,7 +1321,7 @@ int lwm2m_bootstrap_read(lwm2m_context_t * contextP, void * sessionH, lwm2m_uri_
lwm2m_transaction_t * transaction;
bs_data_t * dataP;

LOG_URI(uriP);
LOG_ARG_DBG("%s", LOG_URI_TO_STRING(uriP));

if (uriP
&& (LWM2M_URI_IS_SET_RESOURCE(uriP)
Expand Down
6 changes: 3 additions & 3 deletions core/discover.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ int discover_serialize(lwm2m_context_t * contextP,
lwm2m_attributes_t * paramP;
lwm2m_attributes_t mergedParam;

LOG_ARG("size: %d", size);
LOG_URI(uriP);
LOG_ARG_DBG("size: %d", size);
LOG_ARG_DBG("%s", LOG_URI_TO_STRING(uriP));

head = 0;
LWM2M_URI_RESET(&parentUri);
Expand All @@ -327,7 +327,7 @@ int discover_serialize(lwm2m_context_t * contextP,

// get object level attributes
objParamP = prv_findAttributes(contextP, &tempUri, serverP);

// get object instance level attributes
tempUri.instanceId = uriP->instanceId;
instParamP = prv_findAttributes(contextP, &tempUri, serverP);
Expand Down
Loading
Loading