summaryrefslogtreecommitdiffstats
path: root/examples/protobuf/sensors/tlv.proto
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2023-01-06 18:18:36 +0100
committerAlexey Edelev <alexey.edelev@qt.io>2023-02-13 15:10:52 +0100
commit76d94d29eac9b359cadd4e899a239a727c91d42f (patch)
tree65d0f6328d33da7689f1d85d694e9100fc4e4f04 /examples/protobuf/sensors/tlv.proto
parent1a72cce91d0bcd4e13c5347892abb177f12f971a (diff)
Add example of communication using protobuf messages
Add the protobuf example that emulates the work of dummy sensors that send data to the sensor client. The example uses UDP sockets to send datagrams that contain protobuf messages. Messages consist of two layers: - The Type-Length-Value wrapping message that specifies the the message type and allows to verify the message size. - Sensor message that contains a sensor data. The example intends to show how to generate the code from the protobuf schema and use it in simple UDP signalling protocol on both sender and receiver sides. Both client and emulator have simple UI implemented using QtWidgets. Task-number: QTBUG-109598 Pick-to: 6.5 Change-Id: I13e2c5bcd995b8aa6d873c495a7bd83f6651a061 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'examples/protobuf/sensors/tlv.proto')
-rw-r--r--examples/protobuf/sensors/tlv.proto18
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/protobuf/sensors/tlv.proto b/examples/protobuf/sensors/tlv.proto
new file mode 100644
index 0000000..3d268c3
--- /dev/null
+++ b/examples/protobuf/sensors/tlv.proto
@@ -0,0 +1,18 @@
+syntax = "proto3";
+
+//! [0]
+package qt.examples.sensors.tlv;
+
+enum MessageType {
+ Coordinates = 0;
+ Temperature = 1;
+ WarningNotification = 2;
+}
+
+// Protobuf messages imply inline data size.
+message TlvMessage
+{
+ MessageType type = 1;
+ bytes value = 2;
+}
+//! [0]