Skip to main content

Creating Messages

Qroma - from Protocol Buffers to Language Types

The most important interactions between users and hardware are sending commands and receiving feedback. Consider the commands and data your device will need to send and receive (the inputs and outputs, or I/O). Qroma projects use Protocol Buffers (PB) to define message fields, though I/O can be extended with other method of communication as necessary, especially if more complex or heavier communication patterns become necessary.

There are many software project benefits to creating a single message ONCE and IN ONE PLACE (known as the DRY Principle) and then sharing it between the software applications that will depend on it.

Qroma also emphasizes using as much type information as is possible in each language/platform to prevent out-of-sync message definitions due to developer/workflow error and promotes making changes simultaneously across all platforms and applications that will interact with your device.

Defining your Messages

To review the I/O commands that were already created as part of the project template, run the command to open the PB root directory in a text editor.

qroma pb edit :my-qroma-project

Note: edit commands only work if you have the command code available on the CLI).

You want to be at the my-qroma-project/protobufs directory. Go into the protofiles-in subdirectory next. This is where your project's messages are defined. Your apps will send these to your device and receive them as responses or updates that your device will send to interested recipients.

Compiling your Messages

Once you have your messages, compile them with a qroma docker image that contains compilation tools for building messages for the different tools/languages/platforms that can be used for your qroma software project. Run the command

qroma pb build :my-qroma-project

This compiles the files in protofiles-in and put the compiled versions (currently C, Dart, Typescript, and Python) in corresponding protofiles-out directories in my-qroma-project/protobufs/protofiles-out and project subdirectories.

If you are trying out a proof of concept or doing rapid app development, your development cycle might be to edit/update a .proto file and then make corresponding updates in accompanying directories. With the qroma pb build command, compilation and distribution can be done in a single step. With Intellisense-style editors and compilation errors, your tooling can guide you to the places in your projects where changes are necessary because of message structure updates.