make the uart device init request do all the heavy lifting here

This commit is contained in:
brentru 2023-07-25 16:05:49 -04:00
parent f2f6ff8cd1
commit 1e7d5f25f6
2 changed files with 10 additions and 20 deletions

View file

@ -22,8 +22,7 @@ import "wippersnapper/uart/v1/uart.proto";
message UARTRequest {
option (nanopb_msgopt).submsg_callback = true;
oneof payload {
wippersnapper.uart.v1.UARTInitRequest req_uart_init = 1;
wippersnapper.uart.v1.UARTDeviceAttachRequest req_uart_device_attach = 2;
wippersnapper.uart.v1.UARTDeviceAttachRequest req_uart_device_attach = 1;
}
}
@ -33,8 +32,7 @@ message UARTRequest {
message UARTResponse {
option (nanopb_msgopt).submsg_callback = true;
oneof payload {
wippersnapper.uart.v1.UARTInitResponse resp_uart_init = 1;
wippersnapper.uart.v1.UARTDeviceAttachResponse resp_uart_device_attach = 2;
wippersnapper.uart.v1.UARTDeviceAttachResponse resp_uart_device_attach = 1;
}
}

View file

@ -6,10 +6,10 @@ package wippersnapper.uart.v1;
import "nanopb/nanopb.proto";
/**
* UARTInitRequest represents a message sent from IO to a device to configure
* and begin UART communication.
* UARTBusData represents a message to configure a UART bus for communication with a device.
* NOTE: This message is never sent directly, it is packed inside UARTDeviceAttachRequest.
*/
message UARTInitRequest {
message UARTBusData {
int32 baudrate = 1; /** The baudrate to use for UART communication (may be a common baud rate such as: 1200bps, 2400bps, 4800bps, 19200bps, 38400bps, 57600bps, or 115200bps). */
string pin_rx = 2; /** The pin on which to receive UART stream data. */
string pin_tx = 3; /** The pin on which to transmit UART stream data. */
@ -17,22 +17,14 @@ message UARTInitRequest {
bool is_software_uart = 5; /** Enables software UART. Defaults to False. */
}
/**
* UARTInitResponse represents a message sent from a device to IO to confirm
* that UART communication has been initialized.
*/
message UARTInitResponse {
bool success = 1; /** True if the UARTInitRequest was successful, False if UART bus is already initialized. */
}
/**
* UARTDeviceAttachRequest represents a message sent from IO to a device
* after UART communication has been initialized to attach a device to the
* UART bus.
* to configure the UART bus (if not already configured) and attach a device.
*/
message UARTDeviceAttachRequest {
string device_id = 1; /** The unique identifier of the device to attach to the UART bus, from Adafruit_WipperSnapper_Components. */
int32 polling_interval = 2; /** The polling interval, in milliseconds, to use for the device. */
UARTBusData bus_info = 1; /** The UART bus configuration. */
string device_id = 2; /** The unique identifier of the device to attach to the UART bus, from Adafruit_WipperSnapper_Components. */
int32 polling_interval = 3; /** The polling interval, in milliseconds, to use for the device. */
}
/**
@ -41,5 +33,5 @@ message UARTDeviceAttachRequest {
*/
message UARTDeviceAttachResponse {
string device_id = 1; /** The unique identifier of the device to attach to the UART bus, from Adafruit_WipperSnapper_Components. */
bool success = 2; /** True if the UARTInitRequest was successful, False otherwise. */
bool is_success = 2; /** True if the UARTInitRequest was successful, False otherwise. */
}