-
Notifications
You must be signed in to change notification settings - Fork 64
/
mav2odid.h
105 lines (85 loc) · 4.15 KB
/
mav2odid.h
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
Copyright (C) 2019 Intel Corporation
SPDX-License-Identifier: Apache-2.0
Mavlink to Open Drone ID C Library
Maintainer:
Soren Friis
*/
#ifndef _MAV2ODID_H_
#define _MAV2ODID_H_
#include <opendroneid.h>
/*
// Mavlink internally allocates two global buffers. If this is unacceptable from
// a system perspective, these can be allocated either globally here by
// uncommenting the below code or the below definitions can be changed to
// pointers and the memory allocated somewhere else and the pointers initialized
// before calling any functions in mav2odid.
// If Mavlink's virtual channel functionality is not used, some memory can be
// saved by defining MAVLINK_COMM_NUM_BUFFERS to be equal to 1, before including
// mavlink_types.h
#include "../mavlink_c_library_v2/mavlink_types.h"
#define MAVLINK_EXTERNAL_RX_BUFFER
mavlink_message_t m_mavlink_buffer[MAVLINK_COMM_NUM_BUFFERS];
#define MAVLINK_EXTERNAL_RX_STATUS
mavlink_status_t m_mavlink_status[MAVLINK_COMM_NUM_BUFFERS];
*/
#include <common/mavlink.h>
/*
* Different transmitter implementations will be defining different sets of
* messages to transmit. Therefore, it is possible to override the size of the
* schedule list here. Define DRONEID_SCHEDULER_SIZE to the desired value
* before including mav2odid.h. E.g. "-DDRONEID_SCHEDULER_SIZE=12" when calling
* cmake. NOTE: Do not call the m2o_init() in this case, but create your own
* suitable version of that function.
*/
#ifndef DRONEID_SCHEDULER_SIZE
#define DRONEID_SCHEDULER_SIZE (2 * (4 + ODID_AUTH_MAX_PAGES))
#endif
#if (DRONEID_SCHEDULER_SIZE < 1) || (DRONEID_SCHEDULER_SIZE > 255)
#error "DRONEID_SCHEDULER_SIZE must be between 1 and 255."
#endif
typedef struct {
uint8_t droneidSchedule[DRONEID_SCHEDULER_SIZE];
uint8_t scheduleIdx;
ODID_BasicID_encoded basicIdEnc[ODID_BASIC_ID_MAX_MESSAGES];
ODID_Location_encoded locationEnc;
ODID_Auth_encoded authEnc[ODID_AUTH_MAX_PAGES];
ODID_SelfID_encoded selfIdEnc;
ODID_System_encoded systemEnc;
ODID_OperatorID_encoded operatorIdEnc;
ODID_MessagePack_encoded messagePackEnc;
uint8_t basicIDEncValid[ODID_BASIC_ID_MAX_MESSAGES];
uint8_t locationEncValid;
uint8_t authEncValid[ODID_AUTH_MAX_PAGES];
uint8_t selfIDEncValid;
uint8_t systemEncValid;
uint8_t operatorIDEncValid;
uint8_t messagePackEncValid;
} mav2odid_t;
int m2o_init(mav2odid_t *m2o);
int m2o_cycleMessages(mav2odid_t *m2o, uint8_t *data);
int m2o_collectMessagePack(mav2odid_t *m2o);
int m2o_basicId(mav2odid_t *m2o, mavlink_open_drone_id_basic_id_t *mavBasicId);
int m2o_location(mav2odid_t *m2o, mavlink_open_drone_id_location_t *mavLocation);
int m2o_authentication(mav2odid_t *m2o, mavlink_open_drone_id_authentication_t *mavAuthentication);
int m2o_selfId(mav2odid_t *m2o, mavlink_open_drone_id_self_id_t *mavSelfId);
int m2o_system(mav2odid_t *m2o, mavlink_open_drone_id_system_t *mavSystem);
int m2o_operatorId(mav2odid_t *m2o, mavlink_open_drone_id_operator_id_t *mavOperatorId);
int m2o_messagePack(mav2odid_t *m2o, mavlink_open_drone_id_message_pack_t *mavMessagePack);
ODID_messagetype_t m2o_parseMavlink(mav2odid_t *m2o, uint8_t data);
void m2o_basicId2Mavlink(mavlink_open_drone_id_basic_id_t *mavBasicId,
ODID_BasicID_data *basicId);
void m2o_location2Mavlink(mavlink_open_drone_id_location_t *mavLocation,
ODID_Location_data *location);
void m2o_authentication2Mavlink(mavlink_open_drone_id_authentication_t *mavAuth,
ODID_Auth_data *Auth);
void m2o_selfId2Mavlink(mavlink_open_drone_id_self_id_t *mavSelfID,
ODID_SelfID_data *selfID);
void m2o_system2Mavlink(mavlink_open_drone_id_system_t *mavSystem,
ODID_System_data *system);
void m2o_operatorId2Mavlink(mavlink_open_drone_id_operator_id_t *mavOperatorID,
ODID_OperatorID_data *operatorID);
void m2o_messagePack2Mavlink(mavlink_open_drone_id_message_pack_t *mavMessagePack,
ODID_MessagePack_data *messagePack);
#endif /* _MAV2ODID_H_ */