Skip to content

Commit

Permalink
net: lwm2m_client_utils: Add debug print for ground fix result
Browse files Browse the repository at this point in the history
When we receive Ground Fix results from the server, it helps
testing to see the result code on debug output.

Signed-off-by: Seppo Takalo <[email protected]>
  • Loading branch information
SeppoTakalo committed May 29, 2024
1 parent e5e367d commit be0726c
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions subsys/net/lib/lwm2m_client_utils/lwm2m/ground_fix_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ void ground_fix_set_result_code_cb(ground_fix_get_result_code_cb_t cb)
result_code_cb = cb;
}

static const char *gfix_result_str(int32_t result)
{
switch (result) {
case LOCATION_ASSIST_RESULT_CODE_OK:
return "OK";
case LOCATION_ASSIST_RESULT_CODE_PERMANENT_ERR:
return "Permanent error";
case LOCATION_ASSIST_RESULT_CODE_TEMP_ERR:
return "Temporary error";
case LOCATION_ASSIST_RESULT_CODE_NO_RESP_ERR:
return "No response";
default:
return "Unknown";
}
}

static int ground_fix_result_code_cb(uint16_t obj_inst_id, uint16_t res_id,
uint16_t res_inst_id, uint8_t *data,
uint16_t data_len, bool last_block,
Expand All @@ -80,13 +96,16 @@ static int ground_fix_result_code_cb(uint16_t obj_inst_id, uint16_t res_id,

result = *(int32_t *)data;

if (result != LOCATION_ASSIST_RESULT_CODE_OK) {
LOG_ERR("Ground Fix result %s (%d)", gfix_result_str(result), result);
} else {
LOG_INF("Ground Fix result %s (%d)", gfix_result_str(result), result);
}

if (result_code_cb) {
result_code_cb(result);
}

if (result != LOCATION_ASSIST_RESULT_CODE_OK) {
LOG_ERR("Result code %d", result);
}
return 0;
}

Expand Down

0 comments on commit be0726c

Please sign in to comment.