Skip to content

Commit

Permalink
Merge pull request #79 from mteijiro/mteijiro_add_psn_to_error_logs
Browse files Browse the repository at this point in the history
Add PSNs to unexpected PSN error log
  • Loading branch information
mikehuovila authored Feb 6, 2024
2 parents 94e3f1d + a16ba33 commit 98ec482
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions xp/annotations/gg_annotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ typedef struct {
.error_details = GG_ANNOT_ERR(err), \
.has_error_code = false})

#define GG_LOG_COMMS_ERROR_PSN(err, exp_psn, rec_psn) \
GG_LOG_O_SEVERE(comms_error, {.has_error_details = true, \
.error_details = GG_ANNOT_ERR(err), \
.has_unexpected_psn = true, \
.unexpected_psn = { \
.has_expected_psn = true, \
.expected_psn = exp_psn, \
.has_received_psn = true, \
.received_psn = rec_psn}, \
.has_error_code = false})

#define GG_LOG_COMMS_ERROR_CODE(err, code) \
GG_LOG_O_SEVERE(comms_error, {.has_error_details = true, \
.error_details = GG_ANNOT_ERR(err), \
Expand Down Expand Up @@ -116,5 +127,6 @@ typedef struct {
#define GG_LOG_COMMS_ERROR_EXTRA_CONTEXT_MAX_SIZE (0)
#define GG_LOG_COMMS_ERROR_STRING(err, extra_context)
#define GG_LOG_COMMS_EVENT(event)
#define GG_LOG_COMMS_ERROR_PSN(err, exp_psn, rec_psn)

#endif // GG_CONFIG_ENABLE_ANNOTATIONS
5 changes: 4 additions & 1 deletion xp/gattlink/gg_gattlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,14 +911,17 @@ GG_GattlinkProtocol_HandleDataPacket(GG_GattlinkProtocol* self,
// Not a restransmission, ignore. Should we reset gattlink if too far in the future?
GG_LOG_WARNING("Received PSN (%d) != Expected PSN (%d)", (int)psn,
(int)self->in.next_expected_data_psn);
GG_LOG_COMMS_ERROR(GG_LIB_GATTLINK_UNEXPECTED_PSN);
GG_LOG_COMMS_ERROR_PSN(GG_LIB_GATTLINK_UNEXPECTED_PSN,
(int)self->in.next_expected_data_psn, (int)psn);

return GG_ERROR_GATTLINK_UNEXPECTED_PSN;
}

// The ack for this will be sent later (either when the ack timer expires, or with our outgoing data)
GG_LOG_WARNING("Received previously received PSN (%d) != Expected (%d), Re-acking with last received PSN (%d)",
(int)psn, (int)self->in.next_expected_data_psn, self->out.psn_to_ack_with);
GG_LOG_COMMS_ERROR_PSN(GG_LIB_GATTLINK_UNEXPECTED_PSN,
(int)self->out.psn_to_ack_with, (int)psn);
}

// Increment the number of unacked packets
Expand Down

0 comments on commit 98ec482

Please sign in to comment.