Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_cellular_status.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE CELLULAR_STATUS PACKING
3
4#define MAVLINK_MSG_ID_CELLULAR_STATUS 334
5
6
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 CELLULAR_STATUS_FLAG_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;
16
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
21
22#define MAVLINK_MSG_ID_CELLULAR_STATUS_CRC 72
23#define MAVLINK_MSG_ID_334_CRC 72
24
25
26
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 } \
40}
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 } \
53}
54#endif
55
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
61 *
62 * @param status Cellular modem status
63 * @param failure_reason Failure reason when status in in CELLULAR_STATUS_FLAG_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)
70 */
71static 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)
73{
74#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
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);
83
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;
94
95 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN);
96#endif
97
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);
100}
101
102/**
103 * @brief Pack a cellular_status message
104 * @param system_id ID of this system
105 * @param component_id ID of this component (e.g. 200 for IMU)
106 * @param status MAVLink status structure
107 * @param msg The MAVLink message to compress the data into
108 *
109 * @param status Cellular modem status
110 * @param failure_reason Failure reason when status in in CELLULAR_STATUS_FLAG_FAILED
111 * @param type Cellular network radio type: gsm, cdma, lte...
112 * @param quality Signal quality in percent. If unknown, set to UINT8_MAX
113 * @param mcc Mobile country code. If unknown, set to UINT16_MAX
114 * @param mnc Mobile network code. If unknown, set to UINT16_MAX
115 * @param lac Location area code. If unknown, set to 0
116 * @return length of the message in bytes (excluding serial stream start sign)
117 */
118static inline uint16_t mavlink_msg_cellular_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, 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)
120{
121#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
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);
130
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;
141
142 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN);
143#endif
144
146#if MAVLINK_CRC_EXTRA
147 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_CRC);
148#else
149 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_CELLULAR_STATUS_MIN_LEN, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN);
150#endif
151}
152
153/**
154 * @brief Pack a cellular_status message on a channel
155 * @param system_id ID of this system
156 * @param component_id ID of this component (e.g. 200 for IMU)
157 * @param chan The MAVLink channel this message will be sent over
158 * @param msg The MAVLink message to compress the data into
159 * @param status Cellular modem status
160 * @param failure_reason Failure reason when status in in CELLULAR_STATUS_FLAG_FAILED
161 * @param type Cellular network radio type: gsm, cdma, lte...
162 * @param quality Signal quality in percent. If unknown, set to UINT8_MAX
163 * @param mcc Mobile country code. If unknown, set to UINT16_MAX
164 * @param mnc Mobile network code. If unknown, set to UINT16_MAX
165 * @param lac Location area code. If unknown, set to 0
166 * @return length of the message in bytes (excluding serial stream start sign)
167 */
168static inline uint16_t mavlink_msg_cellular_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
169 mavlink_message_t* msg,
170 uint8_t status,uint8_t failure_reason,uint8_t type,uint8_t quality,uint16_t mcc,uint16_t mnc,uint16_t lac)
171{
172#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
174 _mav_put_uint16_t(buf, 0, mcc);
175 _mav_put_uint16_t(buf, 2, mnc);
176 _mav_put_uint16_t(buf, 4, lac);
177 _mav_put_uint8_t(buf, 6, status);
178 _mav_put_uint8_t(buf, 7, failure_reason);
179 _mav_put_uint8_t(buf, 8, type);
180 _mav_put_uint8_t(buf, 9, quality);
181
182 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN);
183#else
184 mavlink_cellular_status_t packet;
185 packet.mcc = mcc;
186 packet.mnc = mnc;
187 packet.lac = lac;
188 packet.status = status;
189 packet.failure_reason = failure_reason;
190 packet.type = type;
191 packet.quality = quality;
192
193 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN);
194#endif
195
197 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);
198}
199
200/**
201 * @brief Encode a cellular_status struct
202 *
203 * @param system_id ID of this system
204 * @param component_id ID of this component (e.g. 200 for IMU)
205 * @param msg The MAVLink message to compress the data into
206 * @param cellular_status C-struct to read the message contents from
207 */
208static 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)
209{
210 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);
211}
212
213/**
214 * @brief Encode a cellular_status struct on a channel
215 *
216 * @param system_id ID of this system
217 * @param component_id ID of this component (e.g. 200 for IMU)
218 * @param chan The MAVLink channel this message will be sent over
219 * @param msg The MAVLink message to compress the data into
220 * @param cellular_status C-struct to read the message contents from
221 */
222static 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)
223{
224 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);
225}
226
227/**
228 * @brief Encode a cellular_status struct with provided status structure
229 *
230 * @param system_id ID of this system
231 * @param component_id ID of this component (e.g. 200 for IMU)
232 * @param status MAVLink status structure
233 * @param msg The MAVLink message to compress the data into
234 * @param cellular_status C-struct to read the message contents from
235 */
236static inline uint16_t mavlink_msg_cellular_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_cellular_status_t* cellular_status)
237{
238 return mavlink_msg_cellular_status_pack_status(system_id, component_id, _status, msg, cellular_status->status, cellular_status->failure_reason, cellular_status->type, cellular_status->quality, cellular_status->mcc, cellular_status->mnc, cellular_status->lac);
239}
240
241/**
242 * @brief Send a cellular_status message
243 * @param chan MAVLink channel to send the message
244 *
245 * @param status Cellular modem status
246 * @param failure_reason Failure reason when status in in CELLULAR_STATUS_FLAG_FAILED
247 * @param type Cellular network radio type: gsm, cdma, lte...
248 * @param quality Signal quality in percent. If unknown, set to UINT8_MAX
249 * @param mcc Mobile country code. If unknown, set to UINT16_MAX
250 * @param mnc Mobile network code. If unknown, set to UINT16_MAX
251 * @param lac Location area code. If unknown, set to 0
252 */
253#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
254
255static 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)
256{
257#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
258 char buf[MAVLINK_MSG_ID_CELLULAR_STATUS_LEN];
259 _mav_put_uint16_t(buf, 0, mcc);
260 _mav_put_uint16_t(buf, 2, mnc);
261 _mav_put_uint16_t(buf, 4, lac);
262 _mav_put_uint8_t(buf, 6, status);
263 _mav_put_uint8_t(buf, 7, failure_reason);
264 _mav_put_uint8_t(buf, 8, type);
265 _mav_put_uint8_t(buf, 9, quality);
266
267 _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);
268#else
269 mavlink_cellular_status_t packet;
270 packet.mcc = mcc;
271 packet.mnc = mnc;
272 packet.lac = lac;
273 packet.status = status;
274 packet.failure_reason = failure_reason;
275 packet.type = type;
276 packet.quality = quality;
277
278 _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);
279#endif
280}
281
282/**
283 * @brief Send a cellular_status message
284 * @param chan MAVLink channel to send the message
285 * @param struct The MAVLink struct to serialize
286 */
287static inline void mavlink_msg_cellular_status_send_struct(mavlink_channel_t chan, const mavlink_cellular_status_t* cellular_status)
288{
289#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
290 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);
291#else
292 _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);
293#endif
294}
295
296#if MAVLINK_MSG_ID_CELLULAR_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
297/*
298 This variant of _send() can be used to save stack space by reusing
299 memory from the receive buffer. The caller provides a
300 mavlink_message_t which is the size of a full mavlink message. This
301 is usually the receive buffer for the channel, and allows a reply to an
302 incoming message with minimum stack space usage.
303 */
304static 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)
305{
306#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
307 char *buf = (char *)msgbuf;
308 _mav_put_uint16_t(buf, 0, mcc);
309 _mav_put_uint16_t(buf, 2, mnc);
310 _mav_put_uint16_t(buf, 4, lac);
311 _mav_put_uint8_t(buf, 6, status);
312 _mav_put_uint8_t(buf, 7, failure_reason);
313 _mav_put_uint8_t(buf, 8, type);
314 _mav_put_uint8_t(buf, 9, quality);
315
316 _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);
317#else
318 mavlink_cellular_status_t *packet = (mavlink_cellular_status_t *)msgbuf;
319 packet->mcc = mcc;
320 packet->mnc = mnc;
321 packet->lac = lac;
322 packet->status = status;
323 packet->failure_reason = failure_reason;
324 packet->type = type;
325 packet->quality = quality;
326
327 _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);
328#endif
329}
330#endif
331
332#endif
333
334// MESSAGE CELLULAR_STATUS UNPACKING
335
336
337/**
338 * @brief Get field status from cellular_status message
339 *
340 * @return Cellular modem status
341 */
342static inline uint8_t mavlink_msg_cellular_status_get_status(const mavlink_message_t* msg)
343{
344 return _MAV_RETURN_uint8_t(msg, 6);
345}
346
347/**
348 * @brief Get field failure_reason from cellular_status message
349 *
350 * @return Failure reason when status in in CELLULAR_STATUS_FLAG_FAILED
351 */
352static inline uint8_t mavlink_msg_cellular_status_get_failure_reason(const mavlink_message_t* msg)
353{
354 return _MAV_RETURN_uint8_t(msg, 7);
355}
356
357/**
358 * @brief Get field type from cellular_status message
359 *
360 * @return Cellular network radio type: gsm, cdma, lte...
361 */
362static inline uint8_t mavlink_msg_cellular_status_get_type(const mavlink_message_t* msg)
363{
364 return _MAV_RETURN_uint8_t(msg, 8);
365}
366
367/**
368 * @brief Get field quality from cellular_status message
369 *
370 * @return Signal quality in percent. If unknown, set to UINT8_MAX
371 */
372static inline uint8_t mavlink_msg_cellular_status_get_quality(const mavlink_message_t* msg)
373{
374 return _MAV_RETURN_uint8_t(msg, 9);
375}
376
377/**
378 * @brief Get field mcc from cellular_status message
379 *
380 * @return Mobile country code. If unknown, set to UINT16_MAX
381 */
382static inline uint16_t mavlink_msg_cellular_status_get_mcc(const mavlink_message_t* msg)
383{
384 return _MAV_RETURN_uint16_t(msg, 0);
385}
386
387/**
388 * @brief Get field mnc from cellular_status message
389 *
390 * @return Mobile network code. If unknown, set to UINT16_MAX
391 */
392static inline uint16_t mavlink_msg_cellular_status_get_mnc(const mavlink_message_t* msg)
393{
394 return _MAV_RETURN_uint16_t(msg, 2);
395}
396
397/**
398 * @brief Get field lac from cellular_status message
399 *
400 * @return Location area code. If unknown, set to 0
401 */
402static inline uint16_t mavlink_msg_cellular_status_get_lac(const mavlink_message_t* msg)
403{
404 return _MAV_RETURN_uint16_t(msg, 4);
405}
406
407/**
408 * @brief Decode a cellular_status message into a struct
409 *
410 * @param msg The message to decode
411 * @param cellular_status C-struct to decode the message contents into
412 */
413static inline void mavlink_msg_cellular_status_decode(const mavlink_message_t* msg, mavlink_cellular_status_t* cellular_status)
414{
415#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
416 cellular_status->mcc = mavlink_msg_cellular_status_get_mcc(msg);
417 cellular_status->mnc = mavlink_msg_cellular_status_get_mnc(msg);
418 cellular_status->lac = mavlink_msg_cellular_status_get_lac(msg);
419 cellular_status->status = mavlink_msg_cellular_status_get_status(msg);
420 cellular_status->failure_reason = mavlink_msg_cellular_status_get_failure_reason(msg);
421 cellular_status->type = mavlink_msg_cellular_status_get_type(msg);
422 cellular_status->quality = mavlink_msg_cellular_status_get_quality(msg);
423#else
424 uint8_t len = msg->len < MAVLINK_MSG_ID_CELLULAR_STATUS_LEN? msg->len : MAVLINK_MSG_ID_CELLULAR_STATUS_LEN;
425 memset(cellular_status, 0, MAVLINK_MSG_ID_CELLULAR_STATUS_LEN);
426 memcpy(cellular_status, _MAV_PAYLOAD(msg), len);
427#endif
428}