fork/GramFirmware

git clone https://git.julia.blue/fork/GramFirmware

CarVacrebase to configurator818d962

gram
1.6 KiB55 linesraw
1/*
2 * This file is part of HayBox
3 * Copyright (C) 2024 Jonathan Haylett
4 *
5 * HayBox is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this software. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _COMMS_CONFIGURATORBACKEND_HPP
19#define _COMMS_CONFIGURATORBACKEND_HPP
20
21#include "cobs/Print.h"
22#include "cobs/Stream.h"
23#include "core/CommunicationBackend.hpp"
24
25#include <config.pb.h>
26
27class ConfiguratorBackend : public CommunicationBackend {
28  public:
29    ConfiguratorBackend(
30        InputState &inputs,
31        InputSource **input_sources,
32        size_t input_source_count,
33        Config &config,
34        Stream &stream
35    );
36    CommunicationBackendId BackendId();
37    void SendReport();
38
39  private:
40    size_t ReadPacket(uint8_t *buffer, size_t max_len);
41    int ReadByte();
42    void SkipToNextPacket();
43    bool WritePacket(Command command_id, uint8_t *buffer, size_t len);
44    bool HandleUnknownCommand(Command command);
45    bool HandleGetDeviceInfo();
46    bool HandleGetConfig();
47    bool HandleSetConfig();
48
49    packetio::COBSStream _in;
50    packetio::COBSPrint _out;
51    Stream &_base_stream;
52    Config &_config;
53};
54
55#endif