1+ // Code generated by bitproto. DO NOT EDIT.
2+
3+ // Proto drone describes the structure of the drone.
4+
5+ #ifndef __BITPROTO__DRONE_H__
6+ #define __BITPROTO__DRONE_H__ 1
7+
8+ #include <inttypes.h>
9+ #include <stddef.h>
10+ #include <stdint.h>
11+ #ifndef __cplusplus
12+ #include <stdbool.h>
13+ #endif
14+
15+ #if defined(__cplusplus )
16+ extern "C" {
17+ #endif
18+
19+ #define BITPROTO_OPTIMIZATION_MODE 1
20+
21+ typedef int32_t Timestamp ; // 32bit
22+
23+ typedef int32_t TernaryInt32 [3 ]; // 96bit
24+
25+ typedef uint8_t DroneStatus ; // 3bit
26+
27+ #define DRONE_STATUS_UNKNOWN 0
28+ #define DRONE_STATUS_STANDBY 1
29+ #define DRONE_STATUS_RISING 2
30+ #define DRONE_STATUS_LANDING 3
31+ #define DRONE_STATUS_FLYING 4
32+
33+ typedef uint8_t PropellerStatus ; // 2bit
34+
35+ #define PROPELLER_STATUS_UNKNOWN 0
36+ #define PROPELLER_STATUS_IDLE 1
37+ #define PROPELLER_STATUS_ROTATING 2
38+
39+ typedef uint8_t RotatingDirection ; // 2bit
40+
41+ #define ROTATING_DIRECTION_UNKNOWN 0
42+ #define ROTATING_DIRECTION_CLOCK_WISE 1
43+ #define ROTATING_DIRECTION_ANTI_CLOCK_WISE 2
44+
45+ typedef uint8_t PowerStatus ; // 2bit
46+
47+ #define POWER_STATUS_UNKNOWN 0
48+ #define POWER_STATUS_OFF 1
49+ #define POWER_STATUS_ON 2
50+
51+ typedef uint8_t LandingGearStatus ; // 2bit
52+
53+ #define LANDING_GEAR_STATUS_UNKNOWN 0
54+ #define LANDING_GEAR_STATUS_UNFOLDED 1
55+ #define LANDING_GEAR_STATUS_FOLDED 2
56+
57+ // Number of bytes to encode struct Propeller
58+ #define BYTES_LENGTH_PROPELLER 2
59+
60+ struct Propeller {
61+ uint8_t id ; // 8bit
62+ PropellerStatus status ; // 2bit
63+ RotatingDirection direction ; // 2bit
64+ };
65+
66+ // Number of bytes to encode struct Power
67+ #define BYTES_LENGTH_POWER 2
68+
69+ struct Power {
70+ uint8_t battery ; // 8bit
71+ PowerStatus status ; // 2bit
72+ bool is_charging ; // 1bit
73+ };
74+
75+ // Number of bytes to encode struct Network
76+ #define BYTES_LENGTH_NETWORK 5
77+
78+ struct Network {
79+ // Degree of signal, between 1~10.
80+ uint8_t signal ; // 4bit
81+ // The timestamp of the last time received heartbeat packet.
82+ Timestamp heartbeat_at ; // 32bit
83+ };
84+
85+ // Number of bytes to encode struct LandingGear
86+ #define BYTES_LENGTH_LANDING_GEAR 1
87+
88+ struct LandingGear {
89+ LandingGearStatus status ; // 2bit
90+ };
91+
92+ // Number of bytes to encode struct Position
93+ #define BYTES_LENGTH_POSITION 12
94+
95+ struct Position {
96+ uint32_t latitude ; // 32bit
97+ uint32_t longitude ; // 32bit
98+ uint32_t altitude ; // 32bit
99+ };
100+
101+ // Number of bytes to encode struct Pose
102+ #define BYTES_LENGTH_POSE 12
103+
104+ // Pose in flight. https://en.wikipedia.org/wiki/Aircraft_principal_axes
105+ struct Pose {
106+ int32_t yaw ; // 32bit
107+ int32_t pitch ; // 32bit
108+ int32_t roll ; // 32bit
109+ };
110+
111+ // Number of bytes to encode struct Flight
112+ #define BYTES_LENGTH_FLIGHT 36
113+
114+ struct Flight {
115+ struct Pose pose ; // 96bit
116+ // Velocity at X, Y, Z axis.
117+ TernaryInt32 velocity ; // 96bit
118+ // Acceleration at X, Y, Z axis.
119+ TernaryInt32 acceleration ; // 96bit
120+ };
121+
122+ // Number of bytes to encode struct PressureSensor
123+ #define BYTES_LENGTH_PRESSURE_SENSOR 6
124+
125+ struct PressureSensor {
126+ int32_t pressures [2 ]; // 48bit
127+ };
128+
129+ // Number of bytes to encode struct Drone
130+ #define BYTES_LENGTH_DRONE 67
131+
132+ struct Drone {
133+ DroneStatus status ; // 3bit
134+ struct Position position ; // 96bit
135+ struct Flight flight ; // 288bit
136+ struct Propeller propellers [4 ]; // 48bit
137+ struct Power power ; // 11bit
138+ struct Network network ; // 36bit
139+ struct LandingGear landing_gear ; // 2bit
140+ struct PressureSensor pressure_sensor ; // 48bit
141+ };
142+
143+ // Encode struct Drone to given buffer s.
144+ int EncodeDrone (struct Drone * m , unsigned char * s );
145+ // Decode struct Drone from given buffer s.
146+ int DecodeDrone (struct Drone * m , unsigned char * s );
147+
148+ #if defined(__cplusplus )
149+ }
150+ #endif
151+
152+ #endif
0 commit comments