Skip to content

Commit

Permalink
Remove sink id from event status
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneTriomphe committed Jan 10, 2025
1 parent a40af2f commit e0c667a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions lib/wpc_proto/internal_modules/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,23 @@ wp_ErrorCode Common_convert_error_code(app_res_e error)
return ret;
}

void Common_fill_event_header(wp_EventHeader * header_p)
void Common_fill_event_header(wp_EventHeader * header_p, bool has_sink_id)
{
_Static_assert(member_size(wp_EventHeader, gw_id) >= GATEWAY_ID_MAX_SIZE, "Gateway ID too long");
_Static_assert(member_size(wp_EventHeader, sink_id) >= SINK_ID_MAX_SIZE, "Sink ID too long");

*header_p = (wp_EventHeader){
.has_sink_id = (strlen(m_sink_id) != 0),
.has_sink_id = (strlen(m_sink_id) != 0) && has_sink_id,
.has_time_ms_epoch = true,
.time_ms_epoch = Platform_get_timestamp_ms_epoch(),
.event_id = rand() + (((uint64_t) rand()) << 32),
};

strncpy(header_p->gw_id, Common_get_gateway_id(), GATEWAY_ID_MAX_SIZE);
strncpy(header_p->sink_id, Common_get_sink_id(), SINK_ID_MAX_SIZE);
if (header_p->has_sink_id)
{
strncpy(header_p->sink_id, Common_get_sink_id(), SINK_ID_MAX_SIZE);
}
}

void Common_Fill_response_header(wp_ResponseHeader * header_p,
Expand Down
3 changes: 2 additions & 1 deletion lib/wpc_proto/internal_modules/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ wp_ErrorCode Common_convert_error_code(app_res_e error);
/**
* \brief Fill event message header
* \param header_p pointer to header to fill
* \param has_sink_id boolean indicating if sink_id should be included in header
*/
void Common_fill_event_header(wp_EventHeader * header_p);
void Common_fill_event_header(wp_EventHeader * header_p, bool has_sink_id);

/**
* \brief Fill response header
Expand Down
2 changes: 1 addition & 1 deletion lib/wpc_proto/internal_modules/proto_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ static void fill_status_event(wp_StatusEvent * status_event_p,
strncpy(status_event_p->gw_model, Common_get_gateway_model(), GATEWAY_MODEL_MAX_SIZE);
strncpy(status_event_p->gw_version, Common_get_gateway_version(), GATEWAY_VERSION_MAX_SIZE);

Common_fill_event_header(&status_event_p->header);
Common_fill_event_header(&status_event_p->header, false);
}

static bool refresh_full_stack_state()
Expand Down
2 changes: 1 addition & 1 deletion lib/wpc_proto/internal_modules/proto_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static bool onDataReceived(const uint8_t * bytes,
memcpy(message_PacketReceived_p->payload.bytes, bytes, num_bytes);
message_PacketReceived_p->payload.size = num_bytes;

Common_fill_event_header(&message_PacketReceived_p->header);
Common_fill_event_header(&message_PacketReceived_p->header, true);

pb_ostream_t stream = pb_ostream_from_buffer(encoded_message_p, max_encoded_size);

Expand Down

0 comments on commit e0c667a

Please sign in to comment.