Skip to content

Commit

Permalink
Implement GET_STATUS implementation result (#312)
Browse files Browse the repository at this point in the history
* Implement GET_STATUS implementation result

Signed-off-by: Pablo Garrido <[email protected]>

* Apply suggestions from code review

Co-authored-by: Antonio Cuadros <[email protected]>

* Revert "Apply suggestions from code review"

This reverts commit e634979.

Co-authored-by: Antonio Cuadros <[email protected]>
  • Loading branch information
pablogs9 and Acuadros95 authored Mar 9, 2022
1 parent 243b16b commit 160fc85
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
7 changes: 6 additions & 1 deletion include/uxr/client/core/session/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ typedef struct uxrContinuousArgs
size_t data_size;
} uxrContinuousArgs;

typedef uint8_t pong_status_t;
#define NO_PONG_STATUS 0x00
#define PONG_IN_SESSION_STATUS 0x01
#define PONG_NO_SESSION_STATUS 0x02

/**
* @nosubgrouping
*/
Expand Down Expand Up @@ -193,7 +198,7 @@ typedef struct uxrSession
void* on_reply_args;

bool on_data_flag;
bool on_pong_flag;
pong_status_t on_pong_flag;
uxrContinuousArgs continuous_args;

#ifdef UCLIENT_PROFILE_MULTITHREAD
Expand Down
22 changes: 12 additions & 10 deletions src/c/core/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static bool run_session_until_sync(
uxrSession* session,
int timeout);

bool uxr_acknack_pong(
pong_status_t uxr_acknack_pong(
ucdrBuffer* buffer);

//==================================================================
Expand Down Expand Up @@ -626,14 +626,14 @@ void uxr_flash_output_streams(
//==================================================================
// PRIVATE
//==================================================================
bool uxr_acknack_pong(
pong_status_t uxr_acknack_pong(
ucdrBuffer* buffer)
{
bool success = false;
bool ret = false;
bool must_be_read = ucdr_buffer_remaining(buffer) > SUBHEADER_SIZE;
bool active_session = false;

if (must_be_read)
if (ucdr_buffer_remaining(buffer) > SUBHEADER_SIZE)
{
uint8_t id = 0;
uint8_t flags = 0;
Expand All @@ -646,6 +646,8 @@ bool uxr_acknack_pong(
INFO_Payload info_payload;

success &= uxr_deserialize_BaseObjectReply(buffer, &info_payload.base);
active_session = info_payload.base.result.implementation_status;

success &= ucdr_deserialize_bool(buffer, &info_payload.object_info.optional_config);

if (info_payload.object_info.optional_config)
Expand All @@ -667,7 +669,7 @@ bool uxr_acknack_pong(
}
}

return ret;
return ret ? (active_session ? PONG_IN_SESSION_STATUS : PONG_NO_SESSION_STATUS) : NO_PONG_STATUS;
}

bool uxr_run_session_until_pong(
Expand All @@ -679,19 +681,19 @@ bool uxr_run_session_until_pong(

uxr_flash_output_streams(session);

session->on_pong_flag = false;
session->on_pong_flag = NO_PONG_STATUS;
do
{
listen_message_reliably(session, remaining_time);
if (session->on_pong_flag)
if (NO_PONG_STATUS != session->on_pong_flag)
{
break;
}
remaining_time = timeout_ms - (int)(uxr_millis() - start_timestamp);
}
while (remaining_time > 0);

bool ret = session->on_pong_flag;
bool ret = PONG_IN_SESSION_STATUS == session->on_pong_flag;

return ret;
}
Expand Down Expand Up @@ -875,9 +877,9 @@ void read_message(
uxrStreamId id = uxr_stream_id_from_raw(stream_id_raw, UXR_INPUT_STREAM);
read_stream(session, ub, id, seq_num);
}
else if (uxr_acknack_pong(ub))
else
{
session->on_pong_flag = true;
session->on_pong_flag = uxr_acknack_pong(ub);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/c/util/ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
bool serialize_get_info_message(
ucdrBuffer* ub);

bool uxr_acknack_pong(
pong_status_t uxr_acknack_pong(
ucdrBuffer* buffer);

bool listen_info_message(
Expand Down Expand Up @@ -153,7 +153,7 @@ bool listen_info_message(
uint8_t stream_id_raw;
uxrSeqNum seq_num;
uxr_read_session_header(&session_info_fake, &ub, &stream_id_raw, &seq_num);
success &= uxr_acknack_pong(&ub);
success &= NO_PONG_STATUS != uxr_acknack_pong(&ub);
}

return success;
Expand Down

0 comments on commit 160fc85

Please sign in to comment.