diff --git a/common_libraries/comms/comms.c b/common_libraries/comms/comms.c index 5f715a8..bc083b2 100644 --- a/common_libraries/comms/comms.c +++ b/common_libraries/comms/comms.c @@ -91,6 +91,7 @@ static size_t expected_payload_len(uint16_t type) case MSG_TYPE__HEARTBEAT: return 4u; case MSG_TYPE__SET_LED_PWM: return sizeof(uint8_t) + sizeof(float); // 5 case MSG_TYPE__HARDWARE_ERROR: return 2u; + case MSG_TYPE__LED_PANEL_FEEDBACK: return sizeof(uint8_t) + sizeof(float); default: return SIZE_MAX; } } @@ -127,6 +128,10 @@ static size_t pack_payload(const msg_t* msg, uint8_t* out, size_t cap) PACK(out, pos, msg->payload.led_panel_cmd.panel_percent); break; } + case MSG_TYPE__LED_PANEL_FEEDBACK: + PACK(out, pos, msg->payload.led_panel_feedback.led_panel_index); + PACK(out, pos, msg->payload.led_panel_feedback.panel_percent); + break; case MSG_TYPE__HARDWARE_ERROR: PACK(out, pos, msg->payload.hardware_error.error_type); PACK(out, pos, msg->payload.hardware_error.info); @@ -152,6 +157,10 @@ static bool unpack_payload(msg_t* msg, const uint8_t* in, size_t len) UNPACK(in, pos, msg->payload.led_panel_cmd.led_panel_index); UNPACK(in, pos, msg->payload.led_panel_cmd.panel_percent); break; + case MSG_TYPE__LED_PANEL_FEEDBACK: + UNPACK(in, pos, msg->payload.led_panel_feedback.led_panel_index); + UNPACK(in, pos, msg->payload.led_panel_feedback.panel_percent); + break; case MSG_TYPE__HARDWARE_ERROR: UNPACK(in, pos, msg->payload.hardware_error.error_type); UNPACK(in, pos, msg->payload.hardware_error.info); @@ -251,4 +260,4 @@ bool convert_from_raw(const uint8_t* raw_in, encoded_msg_t* out) memset(out->payload, 0, sizeof out->payload); memcpy(out->payload, raw_in + pos, plen); return true; -} \ No newline at end of file +} diff --git a/common_libraries/comms/comms.h b/common_libraries/comms/comms.h index f7852e9..2eb5f89 100644 --- a/common_libraries/comms/comms.h +++ b/common_libraries/comms/comms.h @@ -62,6 +62,11 @@ typedef struct { bool is_response; // A response is the LED controller responding with the currently set value } LedPanelCMD_t; +typedef struct { + uint8_t led_panel_index; + float panel_percent; +} LedPanelFeedback_t; + typedef struct { uint8_t error_type; uint8_t info; @@ -72,6 +77,7 @@ typedef union { Ping_t ping; HeartBeat_t heartbeat; LedPanelCMD_t led_panel_cmd; + LedPanelFeedback_t led_panel_feedback; HardwareError_t hardware_error; } Payload_t; @@ -105,6 +111,7 @@ typedef enum { MSG_TYPE__HEARTBEAT, MSG_TYPE__SET_LED_PWM, MSG_TYPE__HARDWARE_ERROR, // Not really used rn + MSG_TYPE__LED_PANEL_FEEDBACK, NUM_MSG_TYPES } msg_type_t; @@ -130,4 +137,4 @@ bool dlc_to_len(const uint32_t dlc, uint8_t* len_out); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif