1 // automatically generated by the FlatBuffers compiler, do not modify
2
3
4 #ifndef FLATBUFFERS_GENERATED_HOSTMESSAGES_CHRE_FBS_H_
5 #define FLATBUFFERS_GENERATED_HOSTMESSAGES_CHRE_FBS_H_
6
7 #include "flatbuffers/flatbuffers.h"
8
9 namespace chre {
10 namespace fbs {
11
12 struct NanoappMessage;
13
14 struct HubInfoRequest;
15
16 struct HubInfoResponse;
17
18 struct NanoappListRequest;
19
20 struct NanoappListEntry;
21
22 struct NanoappListResponse;
23
24 struct LoadNanoappRequest;
25
26 struct LoadNanoappResponse;
27
28 struct UnloadNanoappRequest;
29
30 struct UnloadNanoappResponse;
31
32 struct LogMessage;
33
34 struct TimeSyncMessage;
35
36 struct DebugDumpRequest;
37
38 struct DebugDumpData;
39
40 struct DebugDumpResponse;
41
42 struct TimeSyncRequest;
43
44 struct LowPowerMicAccessRequest;
45
46 struct LowPowerMicAccessRelease;
47
48 struct HostAddress;
49
50 struct MessageContainer;
51
52 /// A union that joins together all possible messages. Note that in FlatBuffers,
53 /// unions have an implicit type
54 enum class ChreMessage : uint8_t {
55 NONE = 0,
56 NanoappMessage = 1,
57 HubInfoRequest = 2,
58 HubInfoResponse = 3,
59 NanoappListRequest = 4,
60 NanoappListResponse = 5,
61 LoadNanoappRequest = 6,
62 LoadNanoappResponse = 7,
63 UnloadNanoappRequest = 8,
64 UnloadNanoappResponse = 9,
65 LogMessage = 10,
66 TimeSyncMessage = 11,
67 DebugDumpRequest = 12,
68 DebugDumpData = 13,
69 DebugDumpResponse = 14,
70 TimeSyncRequest = 15,
71 LowPowerMicAccessRequest = 16,
72 LowPowerMicAccessRelease = 17,
73 MIN = NONE,
74 MAX = LowPowerMicAccessRelease
75 };
76
EnumNamesChreMessage()77 inline const char **EnumNamesChreMessage() {
78 static const char *names[] = {
79 "NONE",
80 "NanoappMessage",
81 "HubInfoRequest",
82 "HubInfoResponse",
83 "NanoappListRequest",
84 "NanoappListResponse",
85 "LoadNanoappRequest",
86 "LoadNanoappResponse",
87 "UnloadNanoappRequest",
88 "UnloadNanoappResponse",
89 "LogMessage",
90 "TimeSyncMessage",
91 "DebugDumpRequest",
92 "DebugDumpData",
93 "DebugDumpResponse",
94 "TimeSyncRequest",
95 "LowPowerMicAccessRequest",
96 "LowPowerMicAccessRelease",
97 nullptr
98 };
99 return names;
100 }
101
EnumNameChreMessage(ChreMessage e)102 inline const char *EnumNameChreMessage(ChreMessage e) {
103 const size_t index = static_cast<int>(e);
104 return EnumNamesChreMessage()[index];
105 }
106
107 template<typename T> struct ChreMessageTraits {
108 static const ChreMessage enum_value = ChreMessage::NONE;
109 };
110
111 template<> struct ChreMessageTraits<NanoappMessage> {
112 static const ChreMessage enum_value = ChreMessage::NanoappMessage;
113 };
114
115 template<> struct ChreMessageTraits<HubInfoRequest> {
116 static const ChreMessage enum_value = ChreMessage::HubInfoRequest;
117 };
118
119 template<> struct ChreMessageTraits<HubInfoResponse> {
120 static const ChreMessage enum_value = ChreMessage::HubInfoResponse;
121 };
122
123 template<> struct ChreMessageTraits<NanoappListRequest> {
124 static const ChreMessage enum_value = ChreMessage::NanoappListRequest;
125 };
126
127 template<> struct ChreMessageTraits<NanoappListResponse> {
128 static const ChreMessage enum_value = ChreMessage::NanoappListResponse;
129 };
130
131 template<> struct ChreMessageTraits<LoadNanoappRequest> {
132 static const ChreMessage enum_value = ChreMessage::LoadNanoappRequest;
133 };
134
135 template<> struct ChreMessageTraits<LoadNanoappResponse> {
136 static const ChreMessage enum_value = ChreMessage::LoadNanoappResponse;
137 };
138
139 template<> struct ChreMessageTraits<UnloadNanoappRequest> {
140 static const ChreMessage enum_value = ChreMessage::UnloadNanoappRequest;
141 };
142
143 template<> struct ChreMessageTraits<UnloadNanoappResponse> {
144 static const ChreMessage enum_value = ChreMessage::UnloadNanoappResponse;
145 };
146
147 template<> struct ChreMessageTraits<LogMessage> {
148 static const ChreMessage enum_value = ChreMessage::LogMessage;
149 };
150
151 template<> struct ChreMessageTraits<TimeSyncMessage> {
152 static const ChreMessage enum_value = ChreMessage::TimeSyncMessage;
153 };
154
155 template<> struct ChreMessageTraits<DebugDumpRequest> {
156 static const ChreMessage enum_value = ChreMessage::DebugDumpRequest;
157 };
158
159 template<> struct ChreMessageTraits<DebugDumpData> {
160 static const ChreMessage enum_value = ChreMessage::DebugDumpData;
161 };
162
163 template<> struct ChreMessageTraits<DebugDumpResponse> {
164 static const ChreMessage enum_value = ChreMessage::DebugDumpResponse;
165 };
166
167 template<> struct ChreMessageTraits<TimeSyncRequest> {
168 static const ChreMessage enum_value = ChreMessage::TimeSyncRequest;
169 };
170
171 template<> struct ChreMessageTraits<LowPowerMicAccessRequest> {
172 static const ChreMessage enum_value = ChreMessage::LowPowerMicAccessRequest;
173 };
174
175 template<> struct ChreMessageTraits<LowPowerMicAccessRelease> {
176 static const ChreMessage enum_value = ChreMessage::LowPowerMicAccessRelease;
177 };
178
179 bool VerifyChreMessage(flatbuffers::Verifier &verifier, const void *obj, ChreMessage type);
180 bool VerifyChreMessageVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types);
181
182 MANUALLY_ALIGNED_STRUCT(2) HostAddress FLATBUFFERS_FINAL_CLASS {
183 private:
184 uint16_t client_id_;
185
186 public:
187 HostAddress() {
188 memset(this, 0, sizeof(HostAddress));
189 }
190 HostAddress(const HostAddress &_o) {
191 memcpy(this, &_o, sizeof(HostAddress));
192 }
193 HostAddress(uint16_t _client_id)
194 : client_id_(flatbuffers::EndianScalar(_client_id)) {
195 }
196 uint16_t client_id() const {
197 return flatbuffers::EndianScalar(client_id_);
198 }
199 };
200 STRUCT_END(HostAddress, 2);
201
202 /// Represents a message sent to/from a nanoapp from/to a client on the host
203 struct NanoappMessage FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
204 enum {
205 VT_APP_ID = 4,
206 VT_MESSAGE_TYPE = 6,
207 VT_HOST_ENDPOINT = 8,
208 VT_MESSAGE = 10
209 };
210 uint64_t app_id() const {
211 return GetField<uint64_t>(VT_APP_ID, 0);
212 }
213 uint32_t message_type() const {
214 return GetField<uint32_t>(VT_MESSAGE_TYPE, 0);
215 }
216 /// Identifies the host-side endpoint on the host that sent or should receive
217 /// this message. The default value is a special value defined in the HAL and
218 /// elsewhere that indicates that the endpoint is unspecified.
219 uint16_t host_endpoint() const {
220 return GetField<uint16_t>(VT_HOST_ENDPOINT, 65534);
221 }
222 /// Vector containing arbitrary application-specific message data
223 const flatbuffers::Vector<uint8_t> *message() const {
224 return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_MESSAGE);
225 }
226 bool Verify(flatbuffers::Verifier &verifier) const {
227 return VerifyTableStart(verifier) &&
228 VerifyField<uint64_t>(verifier, VT_APP_ID) &&
229 VerifyField<uint32_t>(verifier, VT_MESSAGE_TYPE) &&
230 VerifyField<uint16_t>(verifier, VT_HOST_ENDPOINT) &&
231 VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_MESSAGE) &&
232 verifier.Verify(message()) &&
233 verifier.EndTable();
234 }
235 };
236
237 struct NanoappMessageBuilder {
238 flatbuffers::FlatBufferBuilder &fbb_;
239 flatbuffers::uoffset_t start_;
240 void add_app_id(uint64_t app_id) {
241 fbb_.AddElement<uint64_t>(NanoappMessage::VT_APP_ID, app_id, 0);
242 }
243 void add_message_type(uint32_t message_type) {
244 fbb_.AddElement<uint32_t>(NanoappMessage::VT_MESSAGE_TYPE, message_type, 0);
245 }
246 void add_host_endpoint(uint16_t host_endpoint) {
247 fbb_.AddElement<uint16_t>(NanoappMessage::VT_HOST_ENDPOINT, host_endpoint, 65534);
248 }
249 void add_message(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> message) {
250 fbb_.AddOffset(NanoappMessage::VT_MESSAGE, message);
251 }
252 NanoappMessageBuilder(flatbuffers::FlatBufferBuilder &_fbb)
253 : fbb_(_fbb) {
254 start_ = fbb_.StartTable();
255 }
256 NanoappMessageBuilder &operator=(const NanoappMessageBuilder &);
257 flatbuffers::Offset<NanoappMessage> Finish() {
258 const auto end = fbb_.EndTable(start_, 4);
259 auto o = flatbuffers::Offset<NanoappMessage>(end);
260 fbb_.Required(o, NanoappMessage::VT_MESSAGE);
261 return o;
262 }
263 };
264
265 inline flatbuffers::Offset<NanoappMessage> CreateNanoappMessage(
266 flatbuffers::FlatBufferBuilder &_fbb,
267 uint64_t app_id = 0,
268 uint32_t message_type = 0,
269 uint16_t host_endpoint = 65534,
270 flatbuffers::Offset<flatbuffers::Vector<uint8_t>> message = 0) {
271 NanoappMessageBuilder builder_(_fbb);
272 builder_.add_app_id(app_id);
273 builder_.add_message(message);
274 builder_.add_message_type(message_type);
275 builder_.add_host_endpoint(host_endpoint);
276 return builder_.Finish();
277 }
278
279 inline flatbuffers::Offset<NanoappMessage> CreateNanoappMessageDirect(
280 flatbuffers::FlatBufferBuilder &_fbb,
281 uint64_t app_id = 0,
282 uint32_t message_type = 0,
283 uint16_t host_endpoint = 65534,
284 const std::vector<uint8_t> *message = nullptr) {
285 return chre::fbs::CreateNanoappMessage(
286 _fbb,
287 app_id,
288 message_type,
289 host_endpoint,
290 message ? _fbb.CreateVector<uint8_t>(*message) : 0);
291 }
292
293 struct HubInfoRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
294 bool Verify(flatbuffers::Verifier &verifier) const {
295 return VerifyTableStart(verifier) &&
296 verifier.EndTable();
297 }
298 };
299
300 struct HubInfoRequestBuilder {
301 flatbuffers::FlatBufferBuilder &fbb_;
302 flatbuffers::uoffset_t start_;
303 HubInfoRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb)
304 : fbb_(_fbb) {
305 start_ = fbb_.StartTable();
306 }
307 HubInfoRequestBuilder &operator=(const HubInfoRequestBuilder &);
308 flatbuffers::Offset<HubInfoRequest> Finish() {
309 const auto end = fbb_.EndTable(start_, 0);
310 auto o = flatbuffers::Offset<HubInfoRequest>(end);
311 return o;
312 }
313 };
314
315 inline flatbuffers::Offset<HubInfoRequest> CreateHubInfoRequest(
316 flatbuffers::FlatBufferBuilder &_fbb) {
317 HubInfoRequestBuilder builder_(_fbb);
318 return builder_.Finish();
319 }
320
321 struct HubInfoResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
322 enum {
323 VT_NAME = 4,
324 VT_VENDOR = 6,
325 VT_TOOLCHAIN = 8,
326 VT_PLATFORM_VERSION = 10,
327 VT_TOOLCHAIN_VERSION = 12,
328 VT_PEAK_MIPS = 14,
329 VT_STOPPED_POWER = 16,
330 VT_SLEEP_POWER = 18,
331 VT_PEAK_POWER = 20,
332 VT_MAX_MSG_LEN = 22,
333 VT_PLATFORM_ID = 24,
334 VT_CHRE_PLATFORM_VERSION = 26
335 };
336 /// The name of the hub. Nominally a UTF-8 string, but note that we're not
337 /// using the built-in "string" data type from FlatBuffers here, because the
338 /// generated C++ uses std::string which is not well-supported in CHRE. This
339 /// applies for vendor and toolchain as well.
340 const flatbuffers::Vector<int8_t> *name() const {
341 return GetPointer<const flatbuffers::Vector<int8_t> *>(VT_NAME);
342 }
343 const flatbuffers::Vector<int8_t> *vendor() const {
344 return GetPointer<const flatbuffers::Vector<int8_t> *>(VT_VENDOR);
345 }
346 const flatbuffers::Vector<int8_t> *toolchain() const {
347 return GetPointer<const flatbuffers::Vector<int8_t> *>(VT_TOOLCHAIN);
348 }
349 /// Legacy platform version reported in the HAL; semantics not strictly
350 /// defined
351 uint32_t platform_version() const {
352 return GetField<uint32_t>(VT_PLATFORM_VERSION, 0);
353 }
354 /// Toolchain version reported in the HAL; semantics not strictly defined
355 uint32_t toolchain_version() const {
356 return GetField<uint32_t>(VT_TOOLCHAIN_VERSION, 0);
357 }
358 float peak_mips() const {
359 return GetField<float>(VT_PEAK_MIPS, 0.0f);
360 }
361 float stopped_power() const {
362 return GetField<float>(VT_STOPPED_POWER, 0.0f);
363 }
364 float sleep_power() const {
365 return GetField<float>(VT_SLEEP_POWER, 0.0f);
366 }
367 float peak_power() const {
368 return GetField<float>(VT_PEAK_POWER, 0.0f);
369 }
370 /// Maximum size message that can be sent to a nanoapp
371 uint32_t max_msg_len() const {
372 return GetField<uint32_t>(VT_MAX_MSG_LEN, 0);
373 }
374 /// @see chreGetPlatformId()
375 uint64_t platform_id() const {
376 return GetField<uint64_t>(VT_PLATFORM_ID, 0);
377 }
378 /// @see chreGetVersion()
379 uint32_t chre_platform_version() const {
380 return GetField<uint32_t>(VT_CHRE_PLATFORM_VERSION, 0);
381 }
382 bool Verify(flatbuffers::Verifier &verifier) const {
383 return VerifyTableStart(verifier) &&
384 VerifyField<flatbuffers::uoffset_t>(verifier, VT_NAME) &&
385 verifier.Verify(name()) &&
386 VerifyField<flatbuffers::uoffset_t>(verifier, VT_VENDOR) &&
387 verifier.Verify(vendor()) &&
388 VerifyField<flatbuffers::uoffset_t>(verifier, VT_TOOLCHAIN) &&
389 verifier.Verify(toolchain()) &&
390 VerifyField<uint32_t>(verifier, VT_PLATFORM_VERSION) &&
391 VerifyField<uint32_t>(verifier, VT_TOOLCHAIN_VERSION) &&
392 VerifyField<float>(verifier, VT_PEAK_MIPS) &&
393 VerifyField<float>(verifier, VT_STOPPED_POWER) &&
394 VerifyField<float>(verifier, VT_SLEEP_POWER) &&
395 VerifyField<float>(verifier, VT_PEAK_POWER) &&
396 VerifyField<uint32_t>(verifier, VT_MAX_MSG_LEN) &&
397 VerifyField<uint64_t>(verifier, VT_PLATFORM_ID) &&
398 VerifyField<uint32_t>(verifier, VT_CHRE_PLATFORM_VERSION) &&
399 verifier.EndTable();
400 }
401 };
402
403 struct HubInfoResponseBuilder {
404 flatbuffers::FlatBufferBuilder &fbb_;
405 flatbuffers::uoffset_t start_;
406 void add_name(flatbuffers::Offset<flatbuffers::Vector<int8_t>> name) {
407 fbb_.AddOffset(HubInfoResponse::VT_NAME, name);
408 }
409 void add_vendor(flatbuffers::Offset<flatbuffers::Vector<int8_t>> vendor) {
410 fbb_.AddOffset(HubInfoResponse::VT_VENDOR, vendor);
411 }
412 void add_toolchain(flatbuffers::Offset<flatbuffers::Vector<int8_t>> toolchain) {
413 fbb_.AddOffset(HubInfoResponse::VT_TOOLCHAIN, toolchain);
414 }
415 void add_platform_version(uint32_t platform_version) {
416 fbb_.AddElement<uint32_t>(HubInfoResponse::VT_PLATFORM_VERSION, platform_version, 0);
417 }
418 void add_toolchain_version(uint32_t toolchain_version) {
419 fbb_.AddElement<uint32_t>(HubInfoResponse::VT_TOOLCHAIN_VERSION, toolchain_version, 0);
420 }
421 void add_peak_mips(float peak_mips) {
422 fbb_.AddElement<float>(HubInfoResponse::VT_PEAK_MIPS, peak_mips, 0.0f);
423 }
424 void add_stopped_power(float stopped_power) {
425 fbb_.AddElement<float>(HubInfoResponse::VT_STOPPED_POWER, stopped_power, 0.0f);
426 }
427 void add_sleep_power(float sleep_power) {
428 fbb_.AddElement<float>(HubInfoResponse::VT_SLEEP_POWER, sleep_power, 0.0f);
429 }
430 void add_peak_power(float peak_power) {
431 fbb_.AddElement<float>(HubInfoResponse::VT_PEAK_POWER, peak_power, 0.0f);
432 }
433 void add_max_msg_len(uint32_t max_msg_len) {
434 fbb_.AddElement<uint32_t>(HubInfoResponse::VT_MAX_MSG_LEN, max_msg_len, 0);
435 }
436 void add_platform_id(uint64_t platform_id) {
437 fbb_.AddElement<uint64_t>(HubInfoResponse::VT_PLATFORM_ID, platform_id, 0);
438 }
439 void add_chre_platform_version(uint32_t chre_platform_version) {
440 fbb_.AddElement<uint32_t>(HubInfoResponse::VT_CHRE_PLATFORM_VERSION, chre_platform_version, 0);
441 }
442 HubInfoResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb)
443 : fbb_(_fbb) {
444 start_ = fbb_.StartTable();
445 }
446 HubInfoResponseBuilder &operator=(const HubInfoResponseBuilder &);
447 flatbuffers::Offset<HubInfoResponse> Finish() {
448 const auto end = fbb_.EndTable(start_, 12);
449 auto o = flatbuffers::Offset<HubInfoResponse>(end);
450 return o;
451 }
452 };
453
454 inline flatbuffers::Offset<HubInfoResponse> CreateHubInfoResponse(
455 flatbuffers::FlatBufferBuilder &_fbb,
456 flatbuffers::Offset<flatbuffers::Vector<int8_t>> name = 0,
457 flatbuffers::Offset<flatbuffers::Vector<int8_t>> vendor = 0,
458 flatbuffers::Offset<flatbuffers::Vector<int8_t>> toolchain = 0,
459 uint32_t platform_version = 0,
460 uint32_t toolchain_version = 0,
461 float peak_mips = 0.0f,
462 float stopped_power = 0.0f,
463 float sleep_power = 0.0f,
464 float peak_power = 0.0f,
465 uint32_t max_msg_len = 0,
466 uint64_t platform_id = 0,
467 uint32_t chre_platform_version = 0) {
468 HubInfoResponseBuilder builder_(_fbb);
469 builder_.add_platform_id(platform_id);
470 builder_.add_chre_platform_version(chre_platform_version);
471 builder_.add_max_msg_len(max_msg_len);
472 builder_.add_peak_power(peak_power);
473 builder_.add_sleep_power(sleep_power);
474 builder_.add_stopped_power(stopped_power);
475 builder_.add_peak_mips(peak_mips);
476 builder_.add_toolchain_version(toolchain_version);
477 builder_.add_platform_version(platform_version);
478 builder_.add_toolchain(toolchain);
479 builder_.add_vendor(vendor);
480 builder_.add_name(name);
481 return builder_.Finish();
482 }
483
484 inline flatbuffers::Offset<HubInfoResponse> CreateHubInfoResponseDirect(
485 flatbuffers::FlatBufferBuilder &_fbb,
486 const std::vector<int8_t> *name = nullptr,
487 const std::vector<int8_t> *vendor = nullptr,
488 const std::vector<int8_t> *toolchain = nullptr,
489 uint32_t platform_version = 0,
490 uint32_t toolchain_version = 0,
491 float peak_mips = 0.0f,
492 float stopped_power = 0.0f,
493 float sleep_power = 0.0f,
494 float peak_power = 0.0f,
495 uint32_t max_msg_len = 0,
496 uint64_t platform_id = 0,
497 uint32_t chre_platform_version = 0) {
498 return chre::fbs::CreateHubInfoResponse(
499 _fbb,
500 name ? _fbb.CreateVector<int8_t>(*name) : 0,
501 vendor ? _fbb.CreateVector<int8_t>(*vendor) : 0,
502 toolchain ? _fbb.CreateVector<int8_t>(*toolchain) : 0,
503 platform_version,
504 toolchain_version,
505 peak_mips,
506 stopped_power,
507 sleep_power,
508 peak_power,
509 max_msg_len,
510 platform_id,
511 chre_platform_version);
512 }
513
514 struct NanoappListRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
515 bool Verify(flatbuffers::Verifier &verifier) const {
516 return VerifyTableStart(verifier) &&
517 verifier.EndTable();
518 }
519 };
520
521 struct NanoappListRequestBuilder {
522 flatbuffers::FlatBufferBuilder &fbb_;
523 flatbuffers::uoffset_t start_;
524 NanoappListRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb)
525 : fbb_(_fbb) {
526 start_ = fbb_.StartTable();
527 }
528 NanoappListRequestBuilder &operator=(const NanoappListRequestBuilder &);
529 flatbuffers::Offset<NanoappListRequest> Finish() {
530 const auto end = fbb_.EndTable(start_, 0);
531 auto o = flatbuffers::Offset<NanoappListRequest>(end);
532 return o;
533 }
534 };
535
536 inline flatbuffers::Offset<NanoappListRequest> CreateNanoappListRequest(
537 flatbuffers::FlatBufferBuilder &_fbb) {
538 NanoappListRequestBuilder builder_(_fbb);
539 return builder_.Finish();
540 }
541
542 struct NanoappListEntry FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
543 enum {
544 VT_APP_ID = 4,
545 VT_VERSION = 6,
546 VT_ENABLED = 8,
547 VT_IS_SYSTEM = 10
548 };
549 uint64_t app_id() const {
550 return GetField<uint64_t>(VT_APP_ID, 0);
551 }
552 uint32_t version() const {
553 return GetField<uint32_t>(VT_VERSION, 0);
554 }
555 bool enabled() const {
556 return GetField<uint8_t>(VT_ENABLED, 1) != 0;
557 }
558 /// Whether the nanoapp is a pre-loaded "system" nanoapp, i.e. one that should
559 /// not show up in the list of nanoapps in the context hub HAL. System
560 /// nanoapps are typically used to leverage CHRE for some device functionality
561 /// and do not interact via the context hub HAL.
562 bool is_system() const {
563 return GetField<uint8_t>(VT_IS_SYSTEM, 0) != 0;
564 }
565 bool Verify(flatbuffers::Verifier &verifier) const {
566 return VerifyTableStart(verifier) &&
567 VerifyField<uint64_t>(verifier, VT_APP_ID) &&
568 VerifyField<uint32_t>(verifier, VT_VERSION) &&
569 VerifyField<uint8_t>(verifier, VT_ENABLED) &&
570 VerifyField<uint8_t>(verifier, VT_IS_SYSTEM) &&
571 verifier.EndTable();
572 }
573 };
574
575 struct NanoappListEntryBuilder {
576 flatbuffers::FlatBufferBuilder &fbb_;
577 flatbuffers::uoffset_t start_;
578 void add_app_id(uint64_t app_id) {
579 fbb_.AddElement<uint64_t>(NanoappListEntry::VT_APP_ID, app_id, 0);
580 }
581 void add_version(uint32_t version) {
582 fbb_.AddElement<uint32_t>(NanoappListEntry::VT_VERSION, version, 0);
583 }
584 void add_enabled(bool enabled) {
585 fbb_.AddElement<uint8_t>(NanoappListEntry::VT_ENABLED, static_cast<uint8_t>(enabled), 1);
586 }
587 void add_is_system(bool is_system) {
588 fbb_.AddElement<uint8_t>(NanoappListEntry::VT_IS_SYSTEM, static_cast<uint8_t>(is_system), 0);
589 }
590 NanoappListEntryBuilder(flatbuffers::FlatBufferBuilder &_fbb)
591 : fbb_(_fbb) {
592 start_ = fbb_.StartTable();
593 }
594 NanoappListEntryBuilder &operator=(const NanoappListEntryBuilder &);
595 flatbuffers::Offset<NanoappListEntry> Finish() {
596 const auto end = fbb_.EndTable(start_, 4);
597 auto o = flatbuffers::Offset<NanoappListEntry>(end);
598 return o;
599 }
600 };
601
602 inline flatbuffers::Offset<NanoappListEntry> CreateNanoappListEntry(
603 flatbuffers::FlatBufferBuilder &_fbb,
604 uint64_t app_id = 0,
605 uint32_t version = 0,
606 bool enabled = true,
607 bool is_system = false) {
608 NanoappListEntryBuilder builder_(_fbb);
609 builder_.add_app_id(app_id);
610 builder_.add_version(version);
611 builder_.add_is_system(is_system);
612 builder_.add_enabled(enabled);
613 return builder_.Finish();
614 }
615
616 struct NanoappListResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
617 enum {
618 VT_NANOAPPS = 4
619 };
620 const flatbuffers::Vector<flatbuffers::Offset<NanoappListEntry>> *nanoapps() const {
621 return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<NanoappListEntry>> *>(VT_NANOAPPS);
622 }
623 bool Verify(flatbuffers::Verifier &verifier) const {
624 return VerifyTableStart(verifier) &&
625 VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_NANOAPPS) &&
626 verifier.Verify(nanoapps()) &&
627 verifier.VerifyVectorOfTables(nanoapps()) &&
628 verifier.EndTable();
629 }
630 };
631
632 struct NanoappListResponseBuilder {
633 flatbuffers::FlatBufferBuilder &fbb_;
634 flatbuffers::uoffset_t start_;
635 void add_nanoapps(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<NanoappListEntry>>> nanoapps) {
636 fbb_.AddOffset(NanoappListResponse::VT_NANOAPPS, nanoapps);
637 }
638 NanoappListResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb)
639 : fbb_(_fbb) {
640 start_ = fbb_.StartTable();
641 }
642 NanoappListResponseBuilder &operator=(const NanoappListResponseBuilder &);
643 flatbuffers::Offset<NanoappListResponse> Finish() {
644 const auto end = fbb_.EndTable(start_, 1);
645 auto o = flatbuffers::Offset<NanoappListResponse>(end);
646 fbb_.Required(o, NanoappListResponse::VT_NANOAPPS);
647 return o;
648 }
649 };
650
651 inline flatbuffers::Offset<NanoappListResponse> CreateNanoappListResponse(
652 flatbuffers::FlatBufferBuilder &_fbb,
653 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<NanoappListEntry>>> nanoapps = 0) {
654 NanoappListResponseBuilder builder_(_fbb);
655 builder_.add_nanoapps(nanoapps);
656 return builder_.Finish();
657 }
658
659 inline flatbuffers::Offset<NanoappListResponse> CreateNanoappListResponseDirect(
660 flatbuffers::FlatBufferBuilder &_fbb,
661 const std::vector<flatbuffers::Offset<NanoappListEntry>> *nanoapps = nullptr) {
662 return chre::fbs::CreateNanoappListResponse(
663 _fbb,
664 nanoapps ? _fbb.CreateVector<flatbuffers::Offset<NanoappListEntry>>(*nanoapps) : 0);
665 }
666
667 /// Represents a request for loading a nanoapp.
668 /// The nanaopp can either be requested to be loaded via a file or via a buffer.
669 /// For loading via a file, the following steps will be taken:
670 /// 1. The loader sends a LoadNanoappRequest message to CHRE. app_binary must
671 /// be set for legacy purposes, but should be empty. Additionally,
672 /// fragment_id and total_app_size are unused in this request. The loading
673 /// that happens as part of this request is serialized, but asynchronous
674 /// meaning that load requests will be processed in the order they are sent
675 /// but multiple requests can be outstanding at any given time.
676 /// 2. CHRE stores the filename and waits until its event loop is able to
677 /// process the request.
678 /// 3. Once ready, the nanoapp will be loaded from the file specified in the
679 /// original request and will send a callback indicating the
680 /// completion/failure of the request.
681 /// For loading via a buffer, loading may optionally be fragmented into multiple
682 /// sequential requests, which will follow the following steps:
683 /// 1. The loader sends a LoadNanoappRequest message to CHRE. If the request
684 /// is fragmented, then the fields fragment_id and total_app_size must
685 /// be defined. Once the first fragment is sent to CHRE, all subsequent
686 /// fragments must be delivered before a new LoadNanoappRequest can be
687 /// issued. If a new request is received while a current request has
688 /// outstanding fragments, the current request will be overridden with the
689 /// new one.
690 /// 2. CHRE preallocates the required amount of memory, and loads app_binary,
691 /// appending to already loaded fragments as appropriate.
692 /// 3. If the request is fragmented, then the requestor must sequentially send
693 /// multiple LoadNanoappRequest with incremental nanoapp binary fragments.
694 /// CHRE will respond with LoadNanoappResponse for each request. For
695 /// requests starting from the second fragment, all fields except
696 /// fragment_id and app_binary should be ignored by CHRE.
697 ///
698 /// Once the LoadNanoappRepsonse for the last fragment is received
699 /// by the HAL, the HAL client will receive a callback indicating the
700 /// completion/failure of a load request.
701 ///
702 /// If any request fragment is lost, then the entire load request will be
703 /// considered to have failed. If the request times out (e.g. the requestor
704 /// process crashes), then the load request will be cancelled at CHRE and fail.
705 struct LoadNanoappRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
706 enum {
707 VT_TRANSACTION_ID = 4,
708 VT_APP_ID = 6,
709 VT_APP_VERSION = 8,
710 VT_TARGET_API_VERSION = 10,
711 VT_APP_BINARY = 12,
712 VT_FRAGMENT_ID = 14,
713 VT_TOTAL_APP_SIZE = 16,
714 VT_APP_BINARY_FILE_NAME = 18
715 };
716 uint32_t transaction_id() const {
717 return GetField<uint32_t>(VT_TRANSACTION_ID, 0);
718 }
719 uint64_t app_id() const {
720 return GetField<uint64_t>(VT_APP_ID, 0);
721 }
722 uint32_t app_version() const {
723 return GetField<uint32_t>(VT_APP_VERSION, 0);
724 }
725 uint32_t target_api_version() const {
726 return GetField<uint32_t>(VT_TARGET_API_VERSION, 0);
727 }
728 const flatbuffers::Vector<uint8_t> *app_binary() const {
729 return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_APP_BINARY);
730 }
731 /// Fields that are relevant for fragmented loading
732 /// The framgent count starts at 1 and should end at the total number of
733 /// fragments. For clients that do not support fragmented loading, the
734 /// default behavior should be to assume one fragment.
735 uint32_t fragment_id() const {
736 return GetField<uint32_t>(VT_FRAGMENT_ID, 0);
737 }
738 uint32_t total_app_size() const {
739 return GetField<uint32_t>(VT_TOTAL_APP_SIZE, 0);
740 }
741 /// Null-terminated ASCII string containing the file name that contains the
742 /// app binary to be loaded.
743 const flatbuffers::Vector<int8_t> *app_binary_file_name() const {
744 return GetPointer<const flatbuffers::Vector<int8_t> *>(VT_APP_BINARY_FILE_NAME);
745 }
746 bool Verify(flatbuffers::Verifier &verifier) const {
747 return VerifyTableStart(verifier) &&
748 VerifyField<uint32_t>(verifier, VT_TRANSACTION_ID) &&
749 VerifyField<uint64_t>(verifier, VT_APP_ID) &&
750 VerifyField<uint32_t>(verifier, VT_APP_VERSION) &&
751 VerifyField<uint32_t>(verifier, VT_TARGET_API_VERSION) &&
752 VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_APP_BINARY) &&
753 verifier.Verify(app_binary()) &&
754 VerifyField<uint32_t>(verifier, VT_FRAGMENT_ID) &&
755 VerifyField<uint32_t>(verifier, VT_TOTAL_APP_SIZE) &&
756 VerifyField<flatbuffers::uoffset_t>(verifier, VT_APP_BINARY_FILE_NAME) &&
757 verifier.Verify(app_binary_file_name()) &&
758 verifier.EndTable();
759 }
760 };
761
762 struct LoadNanoappRequestBuilder {
763 flatbuffers::FlatBufferBuilder &fbb_;
764 flatbuffers::uoffset_t start_;
765 void add_transaction_id(uint32_t transaction_id) {
766 fbb_.AddElement<uint32_t>(LoadNanoappRequest::VT_TRANSACTION_ID, transaction_id, 0);
767 }
768 void add_app_id(uint64_t app_id) {
769 fbb_.AddElement<uint64_t>(LoadNanoappRequest::VT_APP_ID, app_id, 0);
770 }
771 void add_app_version(uint32_t app_version) {
772 fbb_.AddElement<uint32_t>(LoadNanoappRequest::VT_APP_VERSION, app_version, 0);
773 }
774 void add_target_api_version(uint32_t target_api_version) {
775 fbb_.AddElement<uint32_t>(LoadNanoappRequest::VT_TARGET_API_VERSION, target_api_version, 0);
776 }
777 void add_app_binary(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> app_binary) {
778 fbb_.AddOffset(LoadNanoappRequest::VT_APP_BINARY, app_binary);
779 }
780 void add_fragment_id(uint32_t fragment_id) {
781 fbb_.AddElement<uint32_t>(LoadNanoappRequest::VT_FRAGMENT_ID, fragment_id, 0);
782 }
783 void add_total_app_size(uint32_t total_app_size) {
784 fbb_.AddElement<uint32_t>(LoadNanoappRequest::VT_TOTAL_APP_SIZE, total_app_size, 0);
785 }
786 void add_app_binary_file_name(flatbuffers::Offset<flatbuffers::Vector<int8_t>> app_binary_file_name) {
787 fbb_.AddOffset(LoadNanoappRequest::VT_APP_BINARY_FILE_NAME, app_binary_file_name);
788 }
789 LoadNanoappRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb)
790 : fbb_(_fbb) {
791 start_ = fbb_.StartTable();
792 }
793 LoadNanoappRequestBuilder &operator=(const LoadNanoappRequestBuilder &);
794 flatbuffers::Offset<LoadNanoappRequest> Finish() {
795 const auto end = fbb_.EndTable(start_, 8);
796 auto o = flatbuffers::Offset<LoadNanoappRequest>(end);
797 fbb_.Required(o, LoadNanoappRequest::VT_APP_BINARY);
798 return o;
799 }
800 };
801
802 inline flatbuffers::Offset<LoadNanoappRequest> CreateLoadNanoappRequest(
803 flatbuffers::FlatBufferBuilder &_fbb,
804 uint32_t transaction_id = 0,
805 uint64_t app_id = 0,
806 uint32_t app_version = 0,
807 uint32_t target_api_version = 0,
808 flatbuffers::Offset<flatbuffers::Vector<uint8_t>> app_binary = 0,
809 uint32_t fragment_id = 0,
810 uint32_t total_app_size = 0,
811 flatbuffers::Offset<flatbuffers::Vector<int8_t>> app_binary_file_name = 0) {
812 LoadNanoappRequestBuilder builder_(_fbb);
813 builder_.add_app_id(app_id);
814 builder_.add_app_binary_file_name(app_binary_file_name);
815 builder_.add_total_app_size(total_app_size);
816 builder_.add_fragment_id(fragment_id);
817 builder_.add_app_binary(app_binary);
818 builder_.add_target_api_version(target_api_version);
819 builder_.add_app_version(app_version);
820 builder_.add_transaction_id(transaction_id);
821 return builder_.Finish();
822 }
823
824 inline flatbuffers::Offset<LoadNanoappRequest> CreateLoadNanoappRequestDirect(
825 flatbuffers::FlatBufferBuilder &_fbb,
826 uint32_t transaction_id = 0,
827 uint64_t app_id = 0,
828 uint32_t app_version = 0,
829 uint32_t target_api_version = 0,
830 const std::vector<uint8_t> *app_binary = nullptr,
831 uint32_t fragment_id = 0,
832 uint32_t total_app_size = 0,
833 const std::vector<int8_t> *app_binary_file_name = nullptr) {
834 return chre::fbs::CreateLoadNanoappRequest(
835 _fbb,
836 transaction_id,
837 app_id,
838 app_version,
839 target_api_version,
840 app_binary ? _fbb.CreateVector<uint8_t>(*app_binary) : 0,
841 fragment_id,
842 total_app_size,
843 app_binary_file_name ? _fbb.CreateVector<int8_t>(*app_binary_file_name) : 0);
844 }
845
846 struct LoadNanoappResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
847 enum {
848 VT_TRANSACTION_ID = 4,
849 VT_SUCCESS = 6,
850 VT_FRAGMENT_ID = 8
851 };
852 uint32_t transaction_id() const {
853 return GetField<uint32_t>(VT_TRANSACTION_ID, 0);
854 }
855 /// Denotes whether a load request succeeded or failed.
856 /// If any fragment of a load request fails, the entire load request for
857 /// the same transaction will fail.
858 bool success() const {
859 return GetField<uint8_t>(VT_SUCCESS, 0) != 0;
860 }
861 /// The fragment count of the load reponse is for.
862 uint32_t fragment_id() const {
863 return GetField<uint32_t>(VT_FRAGMENT_ID, 0);
864 }
865 bool Verify(flatbuffers::Verifier &verifier) const {
866 return VerifyTableStart(verifier) &&
867 VerifyField<uint32_t>(verifier, VT_TRANSACTION_ID) &&
868 VerifyField<uint8_t>(verifier, VT_SUCCESS) &&
869 VerifyField<uint32_t>(verifier, VT_FRAGMENT_ID) &&
870 verifier.EndTable();
871 }
872 };
873
874 struct LoadNanoappResponseBuilder {
875 flatbuffers::FlatBufferBuilder &fbb_;
876 flatbuffers::uoffset_t start_;
877 void add_transaction_id(uint32_t transaction_id) {
878 fbb_.AddElement<uint32_t>(LoadNanoappResponse::VT_TRANSACTION_ID, transaction_id, 0);
879 }
880 void add_success(bool success) {
881 fbb_.AddElement<uint8_t>(LoadNanoappResponse::VT_SUCCESS, static_cast<uint8_t>(success), 0);
882 }
883 void add_fragment_id(uint32_t fragment_id) {
884 fbb_.AddElement<uint32_t>(LoadNanoappResponse::VT_FRAGMENT_ID, fragment_id, 0);
885 }
886 LoadNanoappResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb)
887 : fbb_(_fbb) {
888 start_ = fbb_.StartTable();
889 }
890 LoadNanoappResponseBuilder &operator=(const LoadNanoappResponseBuilder &);
891 flatbuffers::Offset<LoadNanoappResponse> Finish() {
892 const auto end = fbb_.EndTable(start_, 3);
893 auto o = flatbuffers::Offset<LoadNanoappResponse>(end);
894 return o;
895 }
896 };
897
898 inline flatbuffers::Offset<LoadNanoappResponse> CreateLoadNanoappResponse(
899 flatbuffers::FlatBufferBuilder &_fbb,
900 uint32_t transaction_id = 0,
901 bool success = false,
902 uint32_t fragment_id = 0) {
903 LoadNanoappResponseBuilder builder_(_fbb);
904 builder_.add_fragment_id(fragment_id);
905 builder_.add_transaction_id(transaction_id);
906 builder_.add_success(success);
907 return builder_.Finish();
908 }
909
910 struct UnloadNanoappRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
911 enum {
912 VT_TRANSACTION_ID = 4,
913 VT_APP_ID = 6,
914 VT_ALLOW_SYSTEM_NANOAPP_UNLOAD = 8
915 };
916 uint32_t transaction_id() const {
917 return GetField<uint32_t>(VT_TRANSACTION_ID, 0);
918 }
919 uint64_t app_id() const {
920 return GetField<uint64_t>(VT_APP_ID, 0);
921 }
922 /// Set to true to allow this request to unload nanoapps identified as "system
923 /// nanoapps", i.e. ones with is_system set to true in NanoappListResponse.
924 bool allow_system_nanoapp_unload() const {
925 return GetField<uint8_t>(VT_ALLOW_SYSTEM_NANOAPP_UNLOAD, 0) != 0;
926 }
927 bool Verify(flatbuffers::Verifier &verifier) const {
928 return VerifyTableStart(verifier) &&
929 VerifyField<uint32_t>(verifier, VT_TRANSACTION_ID) &&
930 VerifyField<uint64_t>(verifier, VT_APP_ID) &&
931 VerifyField<uint8_t>(verifier, VT_ALLOW_SYSTEM_NANOAPP_UNLOAD) &&
932 verifier.EndTable();
933 }
934 };
935
936 struct UnloadNanoappRequestBuilder {
937 flatbuffers::FlatBufferBuilder &fbb_;
938 flatbuffers::uoffset_t start_;
939 void add_transaction_id(uint32_t transaction_id) {
940 fbb_.AddElement<uint32_t>(UnloadNanoappRequest::VT_TRANSACTION_ID, transaction_id, 0);
941 }
942 void add_app_id(uint64_t app_id) {
943 fbb_.AddElement<uint64_t>(UnloadNanoappRequest::VT_APP_ID, app_id, 0);
944 }
945 void add_allow_system_nanoapp_unload(bool allow_system_nanoapp_unload) {
946 fbb_.AddElement<uint8_t>(UnloadNanoappRequest::VT_ALLOW_SYSTEM_NANOAPP_UNLOAD, static_cast<uint8_t>(allow_system_nanoapp_unload), 0);
947 }
948 UnloadNanoappRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb)
949 : fbb_(_fbb) {
950 start_ = fbb_.StartTable();
951 }
952 UnloadNanoappRequestBuilder &operator=(const UnloadNanoappRequestBuilder &);
953 flatbuffers::Offset<UnloadNanoappRequest> Finish() {
954 const auto end = fbb_.EndTable(start_, 3);
955 auto o = flatbuffers::Offset<UnloadNanoappRequest>(end);
956 return o;
957 }
958 };
959
960 inline flatbuffers::Offset<UnloadNanoappRequest> CreateUnloadNanoappRequest(
961 flatbuffers::FlatBufferBuilder &_fbb,
962 uint32_t transaction_id = 0,
963 uint64_t app_id = 0,
964 bool allow_system_nanoapp_unload = false) {
965 UnloadNanoappRequestBuilder builder_(_fbb);
966 builder_.add_app_id(app_id);
967 builder_.add_transaction_id(transaction_id);
968 builder_.add_allow_system_nanoapp_unload(allow_system_nanoapp_unload);
969 return builder_.Finish();
970 }
971
972 struct UnloadNanoappResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
973 enum {
974 VT_TRANSACTION_ID = 4,
975 VT_SUCCESS = 6
976 };
977 uint32_t transaction_id() const {
978 return GetField<uint32_t>(VT_TRANSACTION_ID, 0);
979 }
980 bool success() const {
981 return GetField<uint8_t>(VT_SUCCESS, 0) != 0;
982 }
983 bool Verify(flatbuffers::Verifier &verifier) const {
984 return VerifyTableStart(verifier) &&
985 VerifyField<uint32_t>(verifier, VT_TRANSACTION_ID) &&
986 VerifyField<uint8_t>(verifier, VT_SUCCESS) &&
987 verifier.EndTable();
988 }
989 };
990
991 struct UnloadNanoappResponseBuilder {
992 flatbuffers::FlatBufferBuilder &fbb_;
993 flatbuffers::uoffset_t start_;
994 void add_transaction_id(uint32_t transaction_id) {
995 fbb_.AddElement<uint32_t>(UnloadNanoappResponse::VT_TRANSACTION_ID, transaction_id, 0);
996 }
997 void add_success(bool success) {
998 fbb_.AddElement<uint8_t>(UnloadNanoappResponse::VT_SUCCESS, static_cast<uint8_t>(success), 0);
999 }
1000 UnloadNanoappResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb)
1001 : fbb_(_fbb) {
1002 start_ = fbb_.StartTable();
1003 }
1004 UnloadNanoappResponseBuilder &operator=(const UnloadNanoappResponseBuilder &);
1005 flatbuffers::Offset<UnloadNanoappResponse> Finish() {
1006 const auto end = fbb_.EndTable(start_, 2);
1007 auto o = flatbuffers::Offset<UnloadNanoappResponse>(end);
1008 return o;
1009 }
1010 };
1011
1012 inline flatbuffers::Offset<UnloadNanoappResponse> CreateUnloadNanoappResponse(
1013 flatbuffers::FlatBufferBuilder &_fbb,
1014 uint32_t transaction_id = 0,
1015 bool success = false) {
1016 UnloadNanoappResponseBuilder builder_(_fbb);
1017 builder_.add_transaction_id(transaction_id);
1018 builder_.add_success(success);
1019 return builder_.Finish();
1020 }
1021
1022 /// Represents log messages from CHRE.
1023 struct LogMessage FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
1024 enum {
1025 VT_BUFFER = 4
1026 };
1027 /// A buffer containing formatted log data. A flat array is used here to avoid
1028 /// overhead in serializing and deserializing. The format is as follows:
1029 ///
1030 /// uint8_t - log level (1 = error, 2 = warning,
1031 /// 3 = info, 4 = debug)
1032 /// uint64_t, little-endian - timestamp in nanoseconds
1033 /// char[] - message to log
1034 /// char, \0 - null-terminator
1035 ///
1036 /// This pattern repeats until the end of the buffer for multiple log
1037 /// messages. The last byte will always be a null-terminator. There are no
1038 /// padding bytes between these fields. Treat this like a packed struct and be
1039 /// cautious with unaligned access when reading/writing this buffer.
1040 const flatbuffers::Vector<int8_t> *buffer() const {
1041 return GetPointer<const flatbuffers::Vector<int8_t> *>(VT_BUFFER);
1042 }
1043 bool Verify(flatbuffers::Verifier &verifier) const {
1044 return VerifyTableStart(verifier) &&
1045 VerifyField<flatbuffers::uoffset_t>(verifier, VT_BUFFER) &&
1046 verifier.Verify(buffer()) &&
1047 verifier.EndTable();
1048 }
1049 };
1050
1051 struct LogMessageBuilder {
1052 flatbuffers::FlatBufferBuilder &fbb_;
1053 flatbuffers::uoffset_t start_;
1054 void add_buffer(flatbuffers::Offset<flatbuffers::Vector<int8_t>> buffer) {
1055 fbb_.AddOffset(LogMessage::VT_BUFFER, buffer);
1056 }
1057 LogMessageBuilder(flatbuffers::FlatBufferBuilder &_fbb)
1058 : fbb_(_fbb) {
1059 start_ = fbb_.StartTable();
1060 }
1061 LogMessageBuilder &operator=(const LogMessageBuilder &);
1062 flatbuffers::Offset<LogMessage> Finish() {
1063 const auto end = fbb_.EndTable(start_, 1);
1064 auto o = flatbuffers::Offset<LogMessage>(end);
1065 return o;
1066 }
1067 };
1068
1069 inline flatbuffers::Offset<LogMessage> CreateLogMessage(
1070 flatbuffers::FlatBufferBuilder &_fbb,
1071 flatbuffers::Offset<flatbuffers::Vector<int8_t>> buffer = 0) {
1072 LogMessageBuilder builder_(_fbb);
1073 builder_.add_buffer(buffer);
1074 return builder_.Finish();
1075 }
1076
1077 inline flatbuffers::Offset<LogMessage> CreateLogMessageDirect(
1078 flatbuffers::FlatBufferBuilder &_fbb,
1079 const std::vector<int8_t> *buffer = nullptr) {
1080 return chre::fbs::CreateLogMessage(
1081 _fbb,
1082 buffer ? _fbb.CreateVector<int8_t>(*buffer) : 0);
1083 }
1084
1085 /// Represents a message sent to CHRE to indicate AP timestamp for time sync
1086 struct TimeSyncMessage FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
1087 enum {
1088 VT_OFFSET = 4
1089 };
1090 /// Offset between AP and CHRE timestamp
1091 int64_t offset() const {
1092 return GetField<int64_t>(VT_OFFSET, 0);
1093 }
1094 bool Verify(flatbuffers::Verifier &verifier) const {
1095 return VerifyTableStart(verifier) &&
1096 VerifyField<int64_t>(verifier, VT_OFFSET) &&
1097 verifier.EndTable();
1098 }
1099 };
1100
1101 struct TimeSyncMessageBuilder {
1102 flatbuffers::FlatBufferBuilder &fbb_;
1103 flatbuffers::uoffset_t start_;
1104 void add_offset(int64_t offset) {
1105 fbb_.AddElement<int64_t>(TimeSyncMessage::VT_OFFSET, offset, 0);
1106 }
1107 TimeSyncMessageBuilder(flatbuffers::FlatBufferBuilder &_fbb)
1108 : fbb_(_fbb) {
1109 start_ = fbb_.StartTable();
1110 }
1111 TimeSyncMessageBuilder &operator=(const TimeSyncMessageBuilder &);
1112 flatbuffers::Offset<TimeSyncMessage> Finish() {
1113 const auto end = fbb_.EndTable(start_, 1);
1114 auto o = flatbuffers::Offset<TimeSyncMessage>(end);
1115 return o;
1116 }
1117 };
1118
1119 inline flatbuffers::Offset<TimeSyncMessage> CreateTimeSyncMessage(
1120 flatbuffers::FlatBufferBuilder &_fbb,
1121 int64_t offset = 0) {
1122 TimeSyncMessageBuilder builder_(_fbb);
1123 builder_.add_offset(offset);
1124 return builder_.Finish();
1125 }
1126
1127 /// A request to gather and return debugging information. Only one debug dump
1128 /// session can be active at a time. Upon accepting a request, zero or more
1129 /// DebugDumpData messages are generated, followed by a DebugDumpResponse
1130 /// indicating the completion of the operation.
1131 struct DebugDumpRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
1132 bool Verify(flatbuffers::Verifier &verifier) const {
1133 return VerifyTableStart(verifier) &&
1134 verifier.EndTable();
1135 }
1136 };
1137
1138 struct DebugDumpRequestBuilder {
1139 flatbuffers::FlatBufferBuilder &fbb_;
1140 flatbuffers::uoffset_t start_;
1141 DebugDumpRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb)
1142 : fbb_(_fbb) {
1143 start_ = fbb_.StartTable();
1144 }
1145 DebugDumpRequestBuilder &operator=(const DebugDumpRequestBuilder &);
1146 flatbuffers::Offset<DebugDumpRequest> Finish() {
1147 const auto end = fbb_.EndTable(start_, 0);
1148 auto o = flatbuffers::Offset<DebugDumpRequest>(end);
1149 return o;
1150 }
1151 };
1152
1153 inline flatbuffers::Offset<DebugDumpRequest> CreateDebugDumpRequest(
1154 flatbuffers::FlatBufferBuilder &_fbb) {
1155 DebugDumpRequestBuilder builder_(_fbb);
1156 return builder_.Finish();
1157 }
1158
1159 struct DebugDumpData FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
1160 enum {
1161 VT_DEBUG_STR = 4
1162 };
1163 /// Null-terminated ASCII string containing debugging information
1164 const flatbuffers::Vector<int8_t> *debug_str() const {
1165 return GetPointer<const flatbuffers::Vector<int8_t> *>(VT_DEBUG_STR);
1166 }
1167 bool Verify(flatbuffers::Verifier &verifier) const {
1168 return VerifyTableStart(verifier) &&
1169 VerifyField<flatbuffers::uoffset_t>(verifier, VT_DEBUG_STR) &&
1170 verifier.Verify(debug_str()) &&
1171 verifier.EndTable();
1172 }
1173 };
1174
1175 struct DebugDumpDataBuilder {
1176 flatbuffers::FlatBufferBuilder &fbb_;
1177 flatbuffers::uoffset_t start_;
1178 void add_debug_str(flatbuffers::Offset<flatbuffers::Vector<int8_t>> debug_str) {
1179 fbb_.AddOffset(DebugDumpData::VT_DEBUG_STR, debug_str);
1180 }
1181 DebugDumpDataBuilder(flatbuffers::FlatBufferBuilder &_fbb)
1182 : fbb_(_fbb) {
1183 start_ = fbb_.StartTable();
1184 }
1185 DebugDumpDataBuilder &operator=(const DebugDumpDataBuilder &);
1186 flatbuffers::Offset<DebugDumpData> Finish() {
1187 const auto end = fbb_.EndTable(start_, 1);
1188 auto o = flatbuffers::Offset<DebugDumpData>(end);
1189 return o;
1190 }
1191 };
1192
1193 inline flatbuffers::Offset<DebugDumpData> CreateDebugDumpData(
1194 flatbuffers::FlatBufferBuilder &_fbb,
1195 flatbuffers::Offset<flatbuffers::Vector<int8_t>> debug_str = 0) {
1196 DebugDumpDataBuilder builder_(_fbb);
1197 builder_.add_debug_str(debug_str);
1198 return builder_.Finish();
1199 }
1200
1201 inline flatbuffers::Offset<DebugDumpData> CreateDebugDumpDataDirect(
1202 flatbuffers::FlatBufferBuilder &_fbb,
1203 const std::vector<int8_t> *debug_str = nullptr) {
1204 return chre::fbs::CreateDebugDumpData(
1205 _fbb,
1206 debug_str ? _fbb.CreateVector<int8_t>(*debug_str) : 0);
1207 }
1208
1209 struct DebugDumpResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
1210 enum {
1211 VT_SUCCESS = 4,
1212 VT_DATA_COUNT = 6
1213 };
1214 /// true if the request was accepted and a dump was performed, false if it was
1215 /// rejected or failed to complete for some reason
1216 bool success() const {
1217 return GetField<uint8_t>(VT_SUCCESS, 0) != 0;
1218 }
1219 /// The number of DebugDumpData messages sent in this session
1220 uint32_t data_count() const {
1221 return GetField<uint32_t>(VT_DATA_COUNT, 0);
1222 }
1223 bool Verify(flatbuffers::Verifier &verifier) const {
1224 return VerifyTableStart(verifier) &&
1225 VerifyField<uint8_t>(verifier, VT_SUCCESS) &&
1226 VerifyField<uint32_t>(verifier, VT_DATA_COUNT) &&
1227 verifier.EndTable();
1228 }
1229 };
1230
1231 struct DebugDumpResponseBuilder {
1232 flatbuffers::FlatBufferBuilder &fbb_;
1233 flatbuffers::uoffset_t start_;
1234 void add_success(bool success) {
1235 fbb_.AddElement<uint8_t>(DebugDumpResponse::VT_SUCCESS, static_cast<uint8_t>(success), 0);
1236 }
1237 void add_data_count(uint32_t data_count) {
1238 fbb_.AddElement<uint32_t>(DebugDumpResponse::VT_DATA_COUNT, data_count, 0);
1239 }
1240 DebugDumpResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb)
1241 : fbb_(_fbb) {
1242 start_ = fbb_.StartTable();
1243 }
1244 DebugDumpResponseBuilder &operator=(const DebugDumpResponseBuilder &);
1245 flatbuffers::Offset<DebugDumpResponse> Finish() {
1246 const auto end = fbb_.EndTable(start_, 2);
1247 auto o = flatbuffers::Offset<DebugDumpResponse>(end);
1248 return o;
1249 }
1250 };
1251
1252 inline flatbuffers::Offset<DebugDumpResponse> CreateDebugDumpResponse(
1253 flatbuffers::FlatBufferBuilder &_fbb,
1254 bool success = false,
1255 uint32_t data_count = 0) {
1256 DebugDumpResponseBuilder builder_(_fbb);
1257 builder_.add_data_count(data_count);
1258 builder_.add_success(success);
1259 return builder_.Finish();
1260 }
1261
1262 /// A request from CHRE for host to initiate a time sync message
1263 /// (system feature, platform-specific - not all platforms necessarily use this)
1264 struct TimeSyncRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
1265 bool Verify(flatbuffers::Verifier &verifier) const {
1266 return VerifyTableStart(verifier) &&
1267 verifier.EndTable();
1268 }
1269 };
1270
1271 struct TimeSyncRequestBuilder {
1272 flatbuffers::FlatBufferBuilder &fbb_;
1273 flatbuffers::uoffset_t start_;
1274 TimeSyncRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb)
1275 : fbb_(_fbb) {
1276 start_ = fbb_.StartTable();
1277 }
1278 TimeSyncRequestBuilder &operator=(const TimeSyncRequestBuilder &);
1279 flatbuffers::Offset<TimeSyncRequest> Finish() {
1280 const auto end = fbb_.EndTable(start_, 0);
1281 auto o = flatbuffers::Offset<TimeSyncRequest>(end);
1282 return o;
1283 }
1284 };
1285
1286 inline flatbuffers::Offset<TimeSyncRequest> CreateTimeSyncRequest(
1287 flatbuffers::FlatBufferBuilder &_fbb) {
1288 TimeSyncRequestBuilder builder_(_fbb);
1289 return builder_.Finish();
1290 }
1291
1292 /// Request from CHRE to enable direct access to data from the low-power
1293 /// microphone. On some systems, coordination via the AP (e.g. with
1294 /// SoundTrigger HAL) is needed to ensure this capability is powered up when
1295 /// CHRE needs it. The host does not send a response.
1296 struct LowPowerMicAccessRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
1297 bool Verify(flatbuffers::Verifier &verifier) const {
1298 return VerifyTableStart(verifier) &&
1299 verifier.EndTable();
1300 }
1301 };
1302
1303 struct LowPowerMicAccessRequestBuilder {
1304 flatbuffers::FlatBufferBuilder &fbb_;
1305 flatbuffers::uoffset_t start_;
1306 LowPowerMicAccessRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb)
1307 : fbb_(_fbb) {
1308 start_ = fbb_.StartTable();
1309 }
1310 LowPowerMicAccessRequestBuilder &operator=(const LowPowerMicAccessRequestBuilder &);
1311 flatbuffers::Offset<LowPowerMicAccessRequest> Finish() {
1312 const auto end = fbb_.EndTable(start_, 0);
1313 auto o = flatbuffers::Offset<LowPowerMicAccessRequest>(end);
1314 return o;
1315 }
1316 };
1317
1318 inline flatbuffers::Offset<LowPowerMicAccessRequest> CreateLowPowerMicAccessRequest(
1319 flatbuffers::FlatBufferBuilder &_fbb) {
1320 LowPowerMicAccessRequestBuilder builder_(_fbb);
1321 return builder_.Finish();
1322 }
1323
1324 /// Notification from CHRE that it no longer needs direct access to low-power
1325 /// microphone data.
1326 struct LowPowerMicAccessRelease FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
1327 bool Verify(flatbuffers::Verifier &verifier) const {
1328 return VerifyTableStart(verifier) &&
1329 verifier.EndTable();
1330 }
1331 };
1332
1333 struct LowPowerMicAccessReleaseBuilder {
1334 flatbuffers::FlatBufferBuilder &fbb_;
1335 flatbuffers::uoffset_t start_;
1336 LowPowerMicAccessReleaseBuilder(flatbuffers::FlatBufferBuilder &_fbb)
1337 : fbb_(_fbb) {
1338 start_ = fbb_.StartTable();
1339 }
1340 LowPowerMicAccessReleaseBuilder &operator=(const LowPowerMicAccessReleaseBuilder &);
1341 flatbuffers::Offset<LowPowerMicAccessRelease> Finish() {
1342 const auto end = fbb_.EndTable(start_, 0);
1343 auto o = flatbuffers::Offset<LowPowerMicAccessRelease>(end);
1344 return o;
1345 }
1346 };
1347
1348 inline flatbuffers::Offset<LowPowerMicAccessRelease> CreateLowPowerMicAccessRelease(
1349 flatbuffers::FlatBufferBuilder &_fbb) {
1350 LowPowerMicAccessReleaseBuilder builder_(_fbb);
1351 return builder_.Finish();
1352 }
1353
1354 /// The top-level container that encapsulates all possible messages. Note that
1355 /// per FlatBuffers requirements, we can't use a union as the top-level
1356 /// structure (root type), so we must wrap it in a table.
1357 struct MessageContainer FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
1358 enum {
1359 VT_MESSAGE_TYPE = 4,
1360 VT_MESSAGE = 6,
1361 VT_HOST_ADDR = 8
1362 };
1363 ChreMessage message_type() const {
1364 return static_cast<ChreMessage>(GetField<uint8_t>(VT_MESSAGE_TYPE, 0));
1365 }
1366 const void *message() const {
1367 return GetPointer<const void *>(VT_MESSAGE);
1368 }
1369 /// The originating or destination client ID on the host side, used to direct
1370 /// responses only to the client that sent the request. Although initially
1371 /// populated by the requesting client, this is enforced to be the correct
1372 /// value by the entity guarding access to CHRE.
1373 /// This is wrapped in a struct to ensure that it is always included when
1374 /// encoding the message, so it can be mutated by the host daemon.
1375 const HostAddress *host_addr() const {
1376 return GetStruct<const HostAddress *>(VT_HOST_ADDR);
1377 }
1378 bool Verify(flatbuffers::Verifier &verifier) const {
1379 return VerifyTableStart(verifier) &&
1380 VerifyField<uint8_t>(verifier, VT_MESSAGE_TYPE) &&
1381 VerifyFieldRequired<flatbuffers::uoffset_t>(verifier, VT_MESSAGE) &&
1382 VerifyChreMessage(verifier, message(), message_type()) &&
1383 VerifyFieldRequired<HostAddress>(verifier, VT_HOST_ADDR) &&
1384 verifier.EndTable();
1385 }
1386 };
1387
1388 struct MessageContainerBuilder {
1389 flatbuffers::FlatBufferBuilder &fbb_;
1390 flatbuffers::uoffset_t start_;
1391 void add_message_type(ChreMessage message_type) {
1392 fbb_.AddElement<uint8_t>(MessageContainer::VT_MESSAGE_TYPE, static_cast<uint8_t>(message_type), 0);
1393 }
1394 void add_message(flatbuffers::Offset<void> message) {
1395 fbb_.AddOffset(MessageContainer::VT_MESSAGE, message);
1396 }
1397 void add_host_addr(const HostAddress *host_addr) {
1398 fbb_.AddStruct(MessageContainer::VT_HOST_ADDR, host_addr);
1399 }
1400 MessageContainerBuilder(flatbuffers::FlatBufferBuilder &_fbb)
1401 : fbb_(_fbb) {
1402 start_ = fbb_.StartTable();
1403 }
1404 MessageContainerBuilder &operator=(const MessageContainerBuilder &);
1405 flatbuffers::Offset<MessageContainer> Finish() {
1406 const auto end = fbb_.EndTable(start_, 3);
1407 auto o = flatbuffers::Offset<MessageContainer>(end);
1408 fbb_.Required(o, MessageContainer::VT_MESSAGE);
1409 fbb_.Required(o, MessageContainer::VT_HOST_ADDR);
1410 return o;
1411 }
1412 };
1413
1414 inline flatbuffers::Offset<MessageContainer> CreateMessageContainer(
1415 flatbuffers::FlatBufferBuilder &_fbb,
1416 ChreMessage message_type = ChreMessage::NONE,
1417 flatbuffers::Offset<void> message = 0,
1418 const HostAddress *host_addr = 0) {
1419 MessageContainerBuilder builder_(_fbb);
1420 builder_.add_host_addr(host_addr);
1421 builder_.add_message(message);
1422 builder_.add_message_type(message_type);
1423 return builder_.Finish();
1424 }
1425
1426 inline bool VerifyChreMessage(flatbuffers::Verifier &verifier, const void *obj, ChreMessage type) {
1427 switch (type) {
1428 case ChreMessage::NONE: {
1429 return true;
1430 }
1431 case ChreMessage::NanoappMessage: {
1432 auto ptr = reinterpret_cast<const NanoappMessage *>(obj);
1433 return verifier.VerifyTable(ptr);
1434 }
1435 case ChreMessage::HubInfoRequest: {
1436 auto ptr = reinterpret_cast<const HubInfoRequest *>(obj);
1437 return verifier.VerifyTable(ptr);
1438 }
1439 case ChreMessage::HubInfoResponse: {
1440 auto ptr = reinterpret_cast<const HubInfoResponse *>(obj);
1441 return verifier.VerifyTable(ptr);
1442 }
1443 case ChreMessage::NanoappListRequest: {
1444 auto ptr = reinterpret_cast<const NanoappListRequest *>(obj);
1445 return verifier.VerifyTable(ptr);
1446 }
1447 case ChreMessage::NanoappListResponse: {
1448 auto ptr = reinterpret_cast<const NanoappListResponse *>(obj);
1449 return verifier.VerifyTable(ptr);
1450 }
1451 case ChreMessage::LoadNanoappRequest: {
1452 auto ptr = reinterpret_cast<const LoadNanoappRequest *>(obj);
1453 return verifier.VerifyTable(ptr);
1454 }
1455 case ChreMessage::LoadNanoappResponse: {
1456 auto ptr = reinterpret_cast<const LoadNanoappResponse *>(obj);
1457 return verifier.VerifyTable(ptr);
1458 }
1459 case ChreMessage::UnloadNanoappRequest: {
1460 auto ptr = reinterpret_cast<const UnloadNanoappRequest *>(obj);
1461 return verifier.VerifyTable(ptr);
1462 }
1463 case ChreMessage::UnloadNanoappResponse: {
1464 auto ptr = reinterpret_cast<const UnloadNanoappResponse *>(obj);
1465 return verifier.VerifyTable(ptr);
1466 }
1467 case ChreMessage::LogMessage: {
1468 auto ptr = reinterpret_cast<const LogMessage *>(obj);
1469 return verifier.VerifyTable(ptr);
1470 }
1471 case ChreMessage::TimeSyncMessage: {
1472 auto ptr = reinterpret_cast<const TimeSyncMessage *>(obj);
1473 return verifier.VerifyTable(ptr);
1474 }
1475 case ChreMessage::DebugDumpRequest: {
1476 auto ptr = reinterpret_cast<const DebugDumpRequest *>(obj);
1477 return verifier.VerifyTable(ptr);
1478 }
1479 case ChreMessage::DebugDumpData: {
1480 auto ptr = reinterpret_cast<const DebugDumpData *>(obj);
1481 return verifier.VerifyTable(ptr);
1482 }
1483 case ChreMessage::DebugDumpResponse: {
1484 auto ptr = reinterpret_cast<const DebugDumpResponse *>(obj);
1485 return verifier.VerifyTable(ptr);
1486 }
1487 case ChreMessage::TimeSyncRequest: {
1488 auto ptr = reinterpret_cast<const TimeSyncRequest *>(obj);
1489 return verifier.VerifyTable(ptr);
1490 }
1491 case ChreMessage::LowPowerMicAccessRequest: {
1492 auto ptr = reinterpret_cast<const LowPowerMicAccessRequest *>(obj);
1493 return verifier.VerifyTable(ptr);
1494 }
1495 case ChreMessage::LowPowerMicAccessRelease: {
1496 auto ptr = reinterpret_cast<const LowPowerMicAccessRelease *>(obj);
1497 return verifier.VerifyTable(ptr);
1498 }
1499 default: return false;
1500 }
1501 }
1502
1503 inline bool VerifyChreMessageVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector<flatbuffers::Offset<void>> *values, const flatbuffers::Vector<uint8_t> *types) {
1504 if (values->size() != types->size()) return false;
1505 for (flatbuffers::uoffset_t i = 0; i < values->size(); ++i) {
1506 if (!VerifyChreMessage(
1507 verifier, values->Get(i), types->GetEnum<ChreMessage>(i))) {
1508 return false;
1509 }
1510 }
1511 return true;
1512 }
1513
1514 inline const chre::fbs::MessageContainer *GetMessageContainer(const void *buf) {
1515 return flatbuffers::GetRoot<chre::fbs::MessageContainer>(buf);
1516 }
1517
1518 inline bool VerifyMessageContainerBuffer(
1519 flatbuffers::Verifier &verifier) {
1520 return verifier.VerifyBuffer<chre::fbs::MessageContainer>(nullptr);
1521 }
1522
1523 inline void FinishMessageContainerBuffer(
1524 flatbuffers::FlatBufferBuilder &fbb,
1525 flatbuffers::Offset<chre::fbs::MessageContainer> root) {
1526 fbb.Finish(root);
1527 }
1528
1529 } // namespace fbs
1530 } // namespace chre
1531
1532 #endif // FLATBUFFERS_GENERATED_HOSTMESSAGES_CHRE_FBS_H_
1533