aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/client.cc
blob: 40ffa36f9015facb61ad06b2450214f3527ac2e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// SPDX-License-Identifier: BSD-3-Clause

#include "client.h"

namespace protocol {

void BaseClient::setDevice(std::shared_ptr<voltronic::Device> device) {
    device_ = std::move(device);
}

std::pair<std::shared_ptr<char>, size_t> BaseClient::runOnDevice(std::string& raw) {
    size_t bufSize = 256;
    std::shared_ptr<char> buf(new char[bufSize]);
    size_t responseSize = device_->run(
        (const u8*)raw.c_str(), raw.size(),
        (u8*)buf.get(), bufSize);

    return std::pair<std::shared_ptr<char>, size_t>(buf, responseSize);
}

}