aboutsummaryrefslogtreecommitdiff
path: root/client/wrapper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/wrapper.cc')
-rw-r--r--client/wrapper.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/client/wrapper.cc b/client/wrapper.cc
index f23b3b4..f9cc3dc 100644
--- a/client/wrapper.cc
+++ b/client/wrapper.cc
@@ -22,6 +22,7 @@
#include "peripheral_manager_client_impl.h"
#include "peripheralmanager/peripheral_manager_client.h"
#include "spi_device_impl.h"
+#include "uart_device_impl.h"
namespace {
@@ -58,6 +59,10 @@ struct BI2cDevice {
I2cDeviceImpl* impl;
};
+struct BUartDevice {
+ UartDeviceImpl* impl;
+};
+
BPeripheralManagerClient* BPeripheralManagerClient_new() {
std::unique_ptr<PeripheralManagerClientImpl> impl(
new PeripheralManagerClientImpl);
@@ -333,3 +338,46 @@ void BI2cDevice_delete(BI2cDevice* device) {
delete device->impl;
delete device;
}
+
+char** BPeripheralManagerClient_listUartDevices(
+ const BPeripheralManagerClient* client, int* num_uart_devices) {
+ std::vector<std::string> list;
+ client->impl->ListUartDevices(&list);
+ *num_uart_devices = list.size();
+ return ConvertStringVectorToC(list);
+}
+
+int BPeripheralManagerClient_openUartDevice(
+ const BPeripheralManagerClient* client,
+ const char* name,
+ BUartDevice** device) {
+ std::unique_ptr<UartDeviceImpl> impl;
+ int ret = client->impl->OpenUartDevice(name, &impl);
+ if (ret == 0) {
+ *device = new BUartDevice{impl.release()};
+ }
+ return ret;
+}
+
+int BUartDevice_setBaudrate(const BUartDevice* device, uint32_t baudrate) {
+ return device->impl->SetBaudrate(baudrate);
+}
+
+int BUartDevice_write(const BUartDevice* device,
+ const void* data,
+ uint32_t size,
+ uint32_t* bytes_written) {
+ return device->impl->Write(data, size, bytes_written);
+}
+
+int BUartDevice_read(const BUartDevice* device,
+ void* data,
+ uint32_t size,
+ uint32_t* bytes_read) {
+ return device->impl->Read(data, size, bytes_read);
+}
+
+void BUartDevice_delete(BUartDevice* device) {
+ delete device->impl;
+ delete device;
+}