Merge pull request #10476 from radiolinkW/RADIOLINKF722
[inav.git] / lib / main / MAVLink / common / mavlink_msg_cellular_status.h
blob5b1c195805cd612b4bb637bf6118d4e1e06298bd
1 #pragma once
2 // MESSAGE CELLULAR_STATUS PACKING
4 #define MAVLINK_MSG_ID_CELLULAR_STATUS 334
7 typedef struct __mavlink_cellular_status_t {
8 uint16_t mcc; /*< Mobile country code. If unknown, set to UINT16_MAX*/
9 uint16_t mnc; /*< Mobile network code. If unknown, set to UINT16_MAX*/
10 uint16_t lac; /*< Location area code. If unknown, set to 0*/
11 uint8_t status; /*< Cellular modem status*/
12 uint8_t failure_reason; /*< Failure reason when status in in CELLUAR_STATUS_FAILED*/
13 uint8_t type; /*< Cellular network radio type: gsm, cdma, lte...*/
14 uint8_t quality; /*< Signal quality in percent. If unknown, set to UINT8_MAX*/
15 } mavlink_cellular_status_t;
17 #define MAVLINK_MSG_ID_CELLULAR_STATUS_LEN 10
18 #define MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN 10
19 #define MAVLINK_MSG_ID_334_LEN 10
20 #define MAVLINK_MSG_ID_334_MIN_LEN 10
22 #define MAVLINK_MSG_ID_CELLULAR_STATUS_CRC 72
23 #define MAVLINK_MSG_ID_334_CRC 72
27 #if MAVLINK_COMMAND_24BIT
28 #define MAVLINK_MESSAGE_INFO_CELLULAR_STATUS { \
29 334, \
30 "CELLULAR_STATUS", \
31 7, \
32 { { "status", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_cellular_status_t, status) }, \
33 { "failure_reason", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_cellular_status_t, failure_reason) }, \
34 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_cellular_status_t, type) }, \
35 { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 9, offsetof(mavlink_cellular_status_t, quality) }, \
36 { "mcc", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_cellular_status_t, mcc) }, \
37 { "mnc", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_cellular_status_t, mnc) }, \
38 { "lac", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_cellular_status_t, lac) }, \
39 } \
41 #else
42 #define MAVLINK_MESSAGE_INFO_CELLULAR_STATUS { \
43 "CELLULAR_STATUS", \
44 7, \
45 { { "status", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_cellular_status_t, status) }, \
46 { "failure_reason", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_cellular_status_t, failure_reason) }, \
47 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_cellular_status_t, type) }, \
48 { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 9, offsetof(mavlink_cellular_status_t, quality) }, \
49 { "mcc", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_cellular_status_t, mcc) }, \
50 { "mnc", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_cellular_status_t, mnc) }, \
51 { "lac", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_cellular_status_t, lac) }, \
52 } \
54 #endif
56 /**
57 * @brief Pack a cellular_status message
58 * @param system_id ID of this system
59 * @param component_id ID of this component (e.g. 200 for IMU)
60 * @param msg The MAVLink message to compress the data into
62 * @param status Cellular modem status
63 * @param failure_reason Failure reason when status in in CELLUAR_STATUS_FAILED
64 * @param type Cellular network radio type: gsm, cdma, lte...
65 * @param quality Signal quality in percent. If unknown, set to UINT8_MAX
66 * @param mcc Mobile country code. If unknown, set to UINT16_MAX
67 * @param mnc Mobile network code. If unknown, set to UINT16_MAX
68 * @param lac Location area code. If unknown, set to 0
69 * @return length of the message in bytes (excluding serial stream start sign)
71 static inline uint16_t mavlink_msg_cellular_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
72 uint8_t status, uint8_t failure_reason, uint8_t type, uint8_t quality, uint16_t mcc, uint16_t mnc, uint16_t lac)
74 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
75 char buf[MAVLINK_MSG_ID_CELLULAR_STATUS_LEN];
76 _mav_put_uint16_t(buf, 0, mcc);
77 _mav_put_uint16_t(buf, 2, mnc);
78 _mav_put_uint16_t(buf, 4, lac);
79 _mav_put_uint8_t(buf, 6, status);
80 _mav_put_uint8_t(buf, 7, failure_reason);
81 _mav_put_uint8_t(buf, 8, type);
82 _mav_put_uint8_t(buf, 9, quality);
84 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN);
85 #else
86 mavlink_cellular_status_t packet;
87 packet.mcc = mcc;
88 packet.mnc = mnc;
89 packet.lac = lac;
90 packet.status = status;
91 packet.failure_reason = failure_reason;
92 packet.type = type;
93 packet.quality = quality;
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN);
96 #endif
98 msg->msgid = MAVLINK_MSG_ID_CELLULAR_STATUS;
99 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_CRC);
103 * @brief Pack a cellular_status message on a channel
104 * @param system_id ID of this system
105 * @param component_id ID of this component (e.g. 200 for IMU)
106 * @param chan The MAVLink channel this message will be sent over
107 * @param msg The MAVLink message to compress the data into
108 * @param status Cellular modem status
109 * @param failure_reason Failure reason when status in in CELLUAR_STATUS_FAILED
110 * @param type Cellular network radio type: gsm, cdma, lte...
111 * @param quality Signal quality in percent. If unknown, set to UINT8_MAX
112 * @param mcc Mobile country code. If unknown, set to UINT16_MAX
113 * @param mnc Mobile network code. If unknown, set to UINT16_MAX
114 * @param lac Location area code. If unknown, set to 0
115 * @return length of the message in bytes (excluding serial stream start sign)
117 static inline uint16_t mavlink_msg_cellular_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
118 mavlink_message_t* msg,
119 uint8_t status,uint8_t failure_reason,uint8_t type,uint8_t quality,uint16_t mcc,uint16_t mnc,uint16_t lac)
121 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
122 char buf[MAVLINK_MSG_ID_CELLULAR_STATUS_LEN];
123 _mav_put_uint16_t(buf, 0, mcc);
124 _mav_put_uint16_t(buf, 2, mnc);
125 _mav_put_uint16_t(buf, 4, lac);
126 _mav_put_uint8_t(buf, 6, status);
127 _mav_put_uint8_t(buf, 7, failure_reason);
128 _mav_put_uint8_t(buf, 8, type);
129 _mav_put_uint8_t(buf, 9, quality);
131 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN);
132 #else
133 mavlink_cellular_status_t packet;
134 packet.mcc = mcc;
135 packet.mnc = mnc;
136 packet.lac = lac;
137 packet.status = status;
138 packet.failure_reason = failure_reason;
139 packet.type = type;
140 packet.quality = quality;
142 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN);
143 #endif
145 msg->msgid = MAVLINK_MSG_ID_CELLULAR_STATUS;
146 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_CRC);
150 * @brief Encode a cellular_status struct
152 * @param system_id ID of this system
153 * @param component_id ID of this component (e.g. 200 for IMU)
154 * @param msg The MAVLink message to compress the data into
155 * @param cellular_status C-struct to read the message contents from
157 static inline uint16_t mavlink_msg_cellular_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_cellular_status_t* cellular_status)
159 return mavlink_msg_cellular_status_pack(system_id, component_id, msg, cellular_status->status, cellular_status->failure_reason, cellular_status->type, cellular_status->quality, cellular_status->mcc, cellular_status->mnc, cellular_status->lac);
163 * @brief Encode a cellular_status struct on a channel
165 * @param system_id ID of this system
166 * @param component_id ID of this component (e.g. 200 for IMU)
167 * @param chan The MAVLink channel this message will be sent over
168 * @param msg The MAVLink message to compress the data into
169 * @param cellular_status C-struct to read the message contents from
171 static inline uint16_t mavlink_msg_cellular_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_cellular_status_t* cellular_status)
173 return mavlink_msg_cellular_status_pack_chan(system_id, component_id, chan, msg, cellular_status->status, cellular_status->failure_reason, cellular_status->type, cellular_status->quality, cellular_status->mcc, cellular_status->mnc, cellular_status->lac);
177 * @brief Send a cellular_status message
178 * @param chan MAVLink channel to send the message
180 * @param status Cellular modem status
181 * @param failure_reason Failure reason when status in in CELLUAR_STATUS_FAILED
182 * @param type Cellular network radio type: gsm, cdma, lte...
183 * @param quality Signal quality in percent. If unknown, set to UINT8_MAX
184 * @param mcc Mobile country code. If unknown, set to UINT16_MAX
185 * @param mnc Mobile network code. If unknown, set to UINT16_MAX
186 * @param lac Location area code. If unknown, set to 0
188 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
190 static inline void mavlink_msg_cellular_status_send(mavlink_channel_t chan, uint8_t status, uint8_t failure_reason, uint8_t type, uint8_t quality, uint16_t mcc, uint16_t mnc, uint16_t lac)
192 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
193 char buf[MAVLINK_MSG_ID_CELLULAR_STATUS_LEN];
194 _mav_put_uint16_t(buf, 0, mcc);
195 _mav_put_uint16_t(buf, 2, mnc);
196 _mav_put_uint16_t(buf, 4, lac);
197 _mav_put_uint8_t(buf, 6, status);
198 _mav_put_uint8_t(buf, 7, failure_reason);
199 _mav_put_uint8_t(buf, 8, type);
200 _mav_put_uint8_t(buf, 9, quality);
202 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CELLULAR_STATUS, buf, MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_CRC);
203 #else
204 mavlink_cellular_status_t packet;
205 packet.mcc = mcc;
206 packet.mnc = mnc;
207 packet.lac = lac;
208 packet.status = status;
209 packet.failure_reason = failure_reason;
210 packet.type = type;
211 packet.quality = quality;
213 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CELLULAR_STATUS, (const char *)&packet, MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_CRC);
214 #endif
218 * @brief Send a cellular_status message
219 * @param chan MAVLink channel to send the message
220 * @param struct The MAVLink struct to serialize
222 static inline void mavlink_msg_cellular_status_send_struct(mavlink_channel_t chan, const mavlink_cellular_status_t* cellular_status)
224 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
225 mavlink_msg_cellular_status_send(chan, cellular_status->status, cellular_status->failure_reason, cellular_status->type, cellular_status->quality, cellular_status->mcc, cellular_status->mnc, cellular_status->lac);
226 #else
227 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CELLULAR_STATUS, (const char *)cellular_status, MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_CRC);
228 #endif
231 #if MAVLINK_MSG_ID_CELLULAR_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
233 This varient of _send() can be used to save stack space by re-using
234 memory from the receive buffer. The caller provides a
235 mavlink_message_t which is the size of a full mavlink message. This
236 is usually the receive buffer for the channel, and allows a reply to an
237 incoming message with minimum stack space usage.
239 static inline void mavlink_msg_cellular_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t status, uint8_t failure_reason, uint8_t type, uint8_t quality, uint16_t mcc, uint16_t mnc, uint16_t lac)
241 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
242 char *buf = (char *)msgbuf;
243 _mav_put_uint16_t(buf, 0, mcc);
244 _mav_put_uint16_t(buf, 2, mnc);
245 _mav_put_uint16_t(buf, 4, lac);
246 _mav_put_uint8_t(buf, 6, status);
247 _mav_put_uint8_t(buf, 7, failure_reason);
248 _mav_put_uint8_t(buf, 8, type);
249 _mav_put_uint8_t(buf, 9, quality);
251 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CELLULAR_STATUS, buf, MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_CRC);
252 #else
253 mavlink_cellular_status_t *packet = (mavlink_cellular_status_t *)msgbuf;
254 packet->mcc = mcc;
255 packet->mnc = mnc;
256 packet->lac = lac;
257 packet->status = status;
258 packet->failure_reason = failure_reason;
259 packet->type = type;
260 packet->quality = quality;
262 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_CELLULAR_STATUS, (const char *)packet, MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_CRC);
263 #endif
265 #endif
267 #endif
269 // MESSAGE CELLULAR_STATUS UNPACKING
273 * @brief Get field status from cellular_status message
275 * @return Cellular modem status
277 static inline uint8_t mavlink_msg_cellular_status_get_status(const mavlink_message_t* msg)
279 return _MAV_RETURN_uint8_t(msg, 6);
283 * @brief Get field failure_reason from cellular_status message
285 * @return Failure reason when status in in CELLUAR_STATUS_FAILED
287 static inline uint8_t mavlink_msg_cellular_status_get_failure_reason(const mavlink_message_t* msg)
289 return _MAV_RETURN_uint8_t(msg, 7);
293 * @brief Get field type from cellular_status message
295 * @return Cellular network radio type: gsm, cdma, lte...
297 static inline uint8_t mavlink_msg_cellular_status_get_type(const mavlink_message_t* msg)
299 return _MAV_RETURN_uint8_t(msg, 8);
303 * @brief Get field quality from cellular_status message
305 * @return Signal quality in percent. If unknown, set to UINT8_MAX
307 static inline uint8_t mavlink_msg_cellular_status_get_quality(const mavlink_message_t* msg)
309 return _MAV_RETURN_uint8_t(msg, 9);
313 * @brief Get field mcc from cellular_status message
315 * @return Mobile country code. If unknown, set to UINT16_MAX
317 static inline uint16_t mavlink_msg_cellular_status_get_mcc(const mavlink_message_t* msg)
319 return _MAV_RETURN_uint16_t(msg, 0);
323 * @brief Get field mnc from cellular_status message
325 * @return Mobile network code. If unknown, set to UINT16_MAX
327 static inline uint16_t mavlink_msg_cellular_status_get_mnc(const mavlink_message_t* msg)
329 return _MAV_RETURN_uint16_t(msg, 2);
333 * @brief Get field lac from cellular_status message
335 * @return Location area code. If unknown, set to 0
337 static inline uint16_t mavlink_msg_cellular_status_get_lac(const mavlink_message_t* msg)
339 return _MAV_RETURN_uint16_t(msg, 4);
343 * @brief Decode a cellular_status message into a struct
345 * @param msg The message to decode
346 * @param cellular_status C-struct to decode the message contents into
348 static inline void mavlink_msg_cellular_status_decode(const mavlink_message_t* msg, mavlink_cellular_status_t* cellular_status)
350 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
351 cellular_status->mcc = mavlink_msg_cellular_status_get_mcc(msg);
352 cellular_status->mnc = mavlink_msg_cellular_status_get_mnc(msg);
353 cellular_status->lac = mavlink_msg_cellular_status_get_lac(msg);
354 cellular_status->status = mavlink_msg_cellular_status_get_status(msg);
355 cellular_status->failure_reason = mavlink_msg_cellular_status_get_failure_reason(msg);
356 cellular_status->type = mavlink_msg_cellular_status_get_type(msg);
357 cellular_status->quality = mavlink_msg_cellular_status_get_quality(msg);
358 #else
359 uint8_t len = msg->len < MAVLINK_MSG_ID_CELLULAR_STATUS_LEN? msg->len : MAVLINK_MSG_ID_CELLULAR_STATUS_LEN;
360 memset(cellular_status, 0, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN);
361 memcpy(cellular_status, _MAV_PAYLOAD(msg), len);
362 #endif