blob: b9b9b6431fab397853fd0ef981bf4de22a6dca29 [file] [log] [blame]
// Copyright 2022 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
#pragma once
#include <pw_hdlc/rpc_channel.h>
#include <pw_hdlc/rpc_packets.h>
#include <pw_rpc/client.h>
#include <pw_stream/stream.h>
#include <array>
#include <atomic>
namespace rpc_demo {
class ClientReader {
public:
ClientReader(pw::stream::Reader& rx, pw::rpc::Client* rpc_client);
bool ParsePacket();
private:
pw::stream::Reader& rx_;
pw::rpc::Client* rpc_client_;
std::array<std::byte, CONFIG_RPC_BUFFER_SIZE> decode_buffer_;
pw::hdlc::Decoder decoder_;
};
} // namespace rpc_demo