-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmain.c
35 lines (26 loc) · 797 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <assert.h>
#include <stdio.h>
#include "example_bp.h"
int main(void) {
// Encode.
struct Drone drone = {0};
drone.status = DRONE_STATUS_RISING;
drone.position.longitude = 2000;
drone.position.latitude = 2000;
drone.position.altitude = 1080;
drone.flight.acceleration[0] = -1001;
drone.power.is_charging = false;
drone.propellers[0].direction = ROTATING_DIRECTION_CLOCK_WISE;
drone.pressure_sensor.pressures[0] = -11;
unsigned char s[BYTES_LENGTH_DRONE] = {0};
EncodeDrone(&drone, s);
// Decode.
struct Drone drone_new = {0};
DecodeDrone(&drone_new, s);
assert(drone_new.status == drone.status);
// Json Formatting.
char buf[512] = {0};
JsonDrone(&drone_new, buf);
printf("%s", buf);
return 0;
}