Skip to content

Commit 160fc85

Browse files
pablogs9Acuadros95
andauthored
Implement GET_STATUS implementation result (#312)
* Implement GET_STATUS implementation result Signed-off-by: Pablo Garrido <pablogs9@gmail.com> * Apply suggestions from code review Co-authored-by: Antonio Cuadros <49162117+Acuadros95@users.noreply.github.com> * Revert "Apply suggestions from code review" This reverts commit e634979. Co-authored-by: Antonio Cuadros <49162117+Acuadros95@users.noreply.github.com>
1 parent 243b16b commit 160fc85

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

include/uxr/client/core/session/session.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ typedef struct uxrContinuousArgs
162162
size_t data_size;
163163
} uxrContinuousArgs;
164164

165+
typedef uint8_t pong_status_t;
166+
#define NO_PONG_STATUS 0x00
167+
#define PONG_IN_SESSION_STATUS 0x01
168+
#define PONG_NO_SESSION_STATUS 0x02
169+
165170
/**
166171
* @nosubgrouping
167172
*/
@@ -193,7 +198,7 @@ typedef struct uxrSession
193198
void* on_reply_args;
194199

195200
bool on_data_flag;
196-
bool on_pong_flag;
201+
pong_status_t on_pong_flag;
197202
uxrContinuousArgs continuous_args;
198203

199204
#ifdef UCLIENT_PROFILE_MULTITHREAD

src/c/core/session/session.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static bool run_session_until_sync(
125125
uxrSession* session,
126126
int timeout);
127127

128-
bool uxr_acknack_pong(
128+
pong_status_t uxr_acknack_pong(
129129
ucdrBuffer* buffer);
130130

131131
//==================================================================
@@ -626,14 +626,14 @@ void uxr_flash_output_streams(
626626
//==================================================================
627627
// PRIVATE
628628
//==================================================================
629-
bool uxr_acknack_pong(
629+
pong_status_t uxr_acknack_pong(
630630
ucdrBuffer* buffer)
631631
{
632632
bool success = false;
633633
bool ret = false;
634-
bool must_be_read = ucdr_buffer_remaining(buffer) > SUBHEADER_SIZE;
634+
bool active_session = false;
635635

636-
if (must_be_read)
636+
if (ucdr_buffer_remaining(buffer) > SUBHEADER_SIZE)
637637
{
638638
uint8_t id = 0;
639639
uint8_t flags = 0;
@@ -646,6 +646,8 @@ bool uxr_acknack_pong(
646646
INFO_Payload info_payload;
647647

648648
success &= uxr_deserialize_BaseObjectReply(buffer, &info_payload.base);
649+
active_session = info_payload.base.result.implementation_status;
650+
649651
success &= ucdr_deserialize_bool(buffer, &info_payload.object_info.optional_config);
650652

651653
if (info_payload.object_info.optional_config)
@@ -667,7 +669,7 @@ bool uxr_acknack_pong(
667669
}
668670
}
669671

670-
return ret;
672+
return ret ? (active_session ? PONG_IN_SESSION_STATUS : PONG_NO_SESSION_STATUS) : NO_PONG_STATUS;
671673
}
672674

673675
bool uxr_run_session_until_pong(
@@ -679,19 +681,19 @@ bool uxr_run_session_until_pong(
679681

680682
uxr_flash_output_streams(session);
681683

682-
session->on_pong_flag = false;
684+
session->on_pong_flag = NO_PONG_STATUS;
683685
do
684686
{
685687
listen_message_reliably(session, remaining_time);
686-
if (session->on_pong_flag)
688+
if (NO_PONG_STATUS != session->on_pong_flag)
687689
{
688690
break;
689691
}
690692
remaining_time = timeout_ms - (int)(uxr_millis() - start_timestamp);
691693
}
692694
while (remaining_time > 0);
693695

694-
bool ret = session->on_pong_flag;
696+
bool ret = PONG_IN_SESSION_STATUS == session->on_pong_flag;
695697

696698
return ret;
697699
}
@@ -875,9 +877,9 @@ void read_message(
875877
uxrStreamId id = uxr_stream_id_from_raw(stream_id_raw, UXR_INPUT_STREAM);
876878
read_stream(session, ub, id, seq_num);
877879
}
878-
else if (uxr_acknack_pong(ub))
880+
else
879881
{
880-
session->on_pong_flag = true;
882+
session->on_pong_flag = uxr_acknack_pong(ub);
881883
}
882884
}
883885

src/c/util/ping.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
bool serialize_get_info_message(
1414
ucdrBuffer* ub);
1515

16-
bool uxr_acknack_pong(
16+
pong_status_t uxr_acknack_pong(
1717
ucdrBuffer* buffer);
1818

1919
bool listen_info_message(
@@ -153,7 +153,7 @@ bool listen_info_message(
153153
uint8_t stream_id_raw;
154154
uxrSeqNum seq_num;
155155
uxr_read_session_header(&session_info_fake, &ub, &stream_id_raw, &seq_num);
156-
success &= uxr_acknack_pong(&ub);
156+
success &= NO_PONG_STATUS != uxr_acknack_pong(&ub);
157157
}
158158

159159
return success;

0 commit comments

Comments
 (0)