/* * GPCommand.cpp * * Created on: Jul 18, 2021 * Author: Andreas Berthoud */ #include "GPCommand.hpp" #include "app_conf.h" #include "stm32_seq.h" GPResponse::GPResponse(com_channel_type_t com_channel_type, uint16_t response_identifier, bool was_successful) : Response(com_channel_type, response_identifier) { (this->payload_ptr + this->get_payload_size())[0] = (uint8_t)was_successful; this->add_to_payload_size(1); } GPRequest::GPRequest(com_channel_type_t com_channel_type, uint8_t * payload_ptr, uint16_t size) : Request(com_channel_type, payload_ptr, size) { uint16_t expected_length = this->buffer_offset + 1; if (expected_length != size) { this->has_error = true; return; } uint8_t * data_ptr = payload_ptr + this->buffer_offset; this->command_id = data_ptr[0]; } GPResponse * GPRequest::execute_request(com_channel_type_t com_channel_type, uint16_t response_identifier) { bool was_successful = true; if (this->has_error) { was_successful = false; } else { switch (this->command_id) { case 1: UTIL_SEQ_SetTask(1<