Commit bdb0410e authored by Kishen Maloor's avatar Kishen Maloor

Add APIs to send/recv CoAP diagnostic messages

Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent 4db15af7
Pipeline #943 passed with stage
in 6 minutes and 31 seconds
......@@ -214,6 +214,20 @@ oc_get_response_payload_raw(oc_client_response_t *response,
return false;
}
bool
oc_get_diagnostic_message(oc_client_response_t *response, const char **msg,
size_t *size)
{
oc_content_format_t cf = 0;
if (oc_get_response_payload_raw(response, (const uint8_t **)msg, size, &cf)) {
if (cf != TEXT_PLAIN) {
return false;
}
return true;
}
return false;
}
bool
oc_do_delete(const char *uri, oc_endpoint_t *endpoint, const char *query,
oc_response_handler_t handler, oc_qos_t qos, void *user_data)
......
......@@ -202,6 +202,14 @@ oc_send_response_raw(oc_request_t *request, const uint8_t *payload, size_t size,
request->response->response_buffer->code = oc_status_code(response_code);
}
void
oc_send_diagnostic_message(oc_request_t *request, const char *msg,
size_t msg_len, oc_status_t response_code)
{
oc_send_response_raw(request, (const uint8_t *)msg, msg_len, TEXT_PLAIN,
response_code);
}
static void
oc_populate_resource_object(oc_resource_t *resource, const char *name,
const char *uri, uint8_t num_resource_types,
......
......@@ -1305,6 +1305,10 @@ void oc_send_response_raw(oc_request_t *request, const uint8_t *payload,
bool oc_get_response_payload_raw(oc_client_response_t *response,
const uint8_t **payload, size_t *size,
oc_content_format_t *content_format);
void oc_send_diagnostic_message(oc_request_t *request, const char *msg,
size_t msg_len, oc_status_t response_code);
bool oc_get_diagnostic_message(oc_client_response_t *response, const char **msg,
size_t *size);
/**
* Ignore the request
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment