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.
45 lines
700 B
45 lines
700 B
/*
|
|
* Command.hpp
|
|
*
|
|
* Created on: Jul 8, 2021
|
|
* Author: Andreas Berthoud
|
|
*/
|
|
|
|
#ifndef SRC_COMMAND_H_
|
|
#define SRC_COMMAND_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
extern "C" void pop_and_execute_commands();
|
|
|
|
typedef enum : uint8_t {
|
|
COMMAND_NONE = 0,
|
|
COMMAND_LOG = 0xff,
|
|
} CommandId;
|
|
|
|
|
|
class Command {
|
|
public:
|
|
CommandId id;
|
|
|
|
Command(CommandId command_id);
|
|
virtual ~Command() {};
|
|
|
|
virtual bool execute() = 0;
|
|
|
|
protected:
|
|
uint8_t data[512];
|
|
uint8_t * payload_ptr;
|
|
const int max_payload_length = 507;
|
|
|
|
void set_payload_length(uint16_t length);
|
|
uint16_t get_payload_length();
|
|
|
|
private:
|
|
uint16_t payload_length;
|
|
|
|
};
|
|
|
|
void push_command(Command * command);
|
|
|
|
#endif /* SRC_COMMAND_H_ */
|
|
|