Add function to get size of message by command ID

refactor
PgSocks 2 years ago
parent 77000b525f
commit c4c5e394af

@ -259,3 +259,27 @@ enum MESSAGEERR {
enum MESSAGEERR
message_validate(const union Message* message);
static
inline
size_t
message_length(uint16_t cmd) {
switch(cmd) {
case SET_SDK_CONNECTION_CMD:
return sizeof(struct SetSdkConnectionReq);
case SDK_HEARTBEAT_CMD:
return sizeof(struct SdkHeartbeatReq);
case SET_SDK_MODE_CMD:
return sizeof(struct SetSdkModeReq);
case SET_SYSTEM_LED_CMD:
return sizeof(struct SetSystemLedReq);
case SET_ROBOT_MODE_CMD:
return sizeof(struct SetRobotModeReq);
case SUBNODE_RESET_CMD:
return sizeof(struct SubNodeResetReq);
case SUBSCRIBE_ADD_NODE_CMD:
return sizeof(struct SubscribeAddNodeReq);
default:
return 0;
}
}

Loading…
Cancel
Save