37 lines
No EOL
1.6 KiB
C
37 lines
No EOL
1.6 KiB
C
#pragma once
|
|
#include "protocol.h"
|
|
#define HYDROLINK_MSG_ID_GET_RESPONSE 5
|
|
#define HYDROLINK_MSG_ID_GET_RESPONSE_LEN 6
|
|
#define HYDROLINK_MSG_ID_5_LEN 6
|
|
#define HYDROLINK_MSG_ID_GET_RESPONSE_CRC_EXTRA 28
|
|
|
|
typedef struct hydrolink_msg_get_response_t_s {
|
|
int32_t value; ///
|
|
uint8_t result; ///
|
|
uint8_t cmd_id; ///
|
|
} hydrolink_msg_get_response_t;
|
|
|
|
void hydrolink_get_response_msg_encode(uint8_t src_id, uint8_t dst_id, const hydrolink_msg_get_response_t *msg, hydrolink_msg_t *packet) {
|
|
packet->id = HYDROLINK_MSG_ID_GET_RESPONSE;
|
|
packet->src_id = src_id;
|
|
packet->dst_id = dst_id;
|
|
packet->payload_length = HYDROLINK_MSG_ID_5_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
|
hydrolink_put_int32_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 0, msg->value);
|
|
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 4, msg->result);
|
|
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 5, msg->cmd_id);
|
|
}
|
|
|
|
static inline int32_t hydrolink_msg_get_response_get_value(const hydrolink_msg_t *packet) {
|
|
return HYDROLINK_RETURN_int32_t(packet, 0);
|
|
}
|
|
static inline uint8_t hydrolink_msg_get_response_get_result(const hydrolink_msg_t *packet) {
|
|
return HYDROLINK_RETURN_uint8_t(packet, 4);
|
|
}
|
|
static inline uint8_t hydrolink_msg_get_response_get_cmd_id(const hydrolink_msg_t *packet) {
|
|
return HYDROLINK_RETURN_uint8_t(packet, 5);
|
|
}
|
|
static inline void hydrolink_msgget_response_decode(const hydrolink_msg_t *packet, hydrolink_msg_get_response_t *get_response) {
|
|
get_response->value = hydrolink_msg_get_response_get_value(packet);
|
|
get_response->result = hydrolink_msg_get_response_get_result(packet);
|
|
get_response->cmd_id = hydrolink_msg_get_response_get_cmd_id(packet);
|
|
} |