You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

74 lines
1.4 KiB

/*
* LedCommand.hpp
*
* Created on: Jul 16, 2021
* Author: Andreas Berthoud
*/
#ifndef LEDCOMMAND_HPP_
#define LEDCOMMAND_HPP_
#include "Request.hpp"
#include "Response.hpp"
class LedResponse : public Response {
public:
LedResponse(com_channel_type_t com_channel_type, uint16_t response_identifier, bool was_successful);
CommandId get_command_id() override { return COMMAND_LED_RESPONSE; }
private:
bool was_successful = false;
};
class LedRequest : public Request {
public:
/**
* @brief Construct a new Led Request object
*
* @param payload_ptr
* HEADER | led_id | led_command |
* | 1 byte | 1 byte |
*
* led_id
* -------
* 0: green
* 1: red
* 2: blue
*
* led_command
* -----------
* 0: off
* 1: on
* 2: toggle
*
* @param size
*/
LedRequest(com_channel_type_t com_channel_type, uint8_t * payload_ptr, uint16_t size);
enum LedID {
greed_led,
greed_red,
greed_blue,
led_id_max,
};
enum LedCommand {
led_off,
led_on,
led_toggle,
led_command_max,
};
LedResponse * execute_request(com_channel_type_t com_channel_type, uint16_t response_identifier) override;
CommandId get_command_id() override { return COMMAND_LED_REQUEST; }
private:
bool has_error = false;
LedID led_id = greed_led;
LedCommand led_command = led_off;
};
#endif /* LEDCOMMAND_HPP_ */