2 // MESSAGE SMART_BATTERY_INFO PACKING
4 #define MAVLINK_MSG_ID_SMART_BATTERY_INFO 370
7 typedef struct __mavlink_smart_battery_info_t
{
8 int32_t capacity_full_specification
; /*< [mAh] Capacity when full according to manufacturer, -1: field not provided.*/
9 int32_t capacity_full
; /*< [mAh] Capacity when full (accounting for battery degradation), -1: field not provided.*/
10 uint16_t cycle_count
; /*< Charge/discharge cycle count. UINT16_MAX: field not provided.*/
11 uint16_t weight
; /*< [g] Battery weight. 0: field not provided.*/
12 uint16_t discharge_minimum_voltage
; /*< [mV] Minimum per-cell voltage when discharging. If not supplied set to UINT16_MAX value.*/
13 uint16_t charging_minimum_voltage
; /*< [mV] Minimum per-cell voltage when charging. If not supplied set to UINT16_MAX value.*/
14 uint16_t resting_minimum_voltage
; /*< [mV] Minimum per-cell voltage when resting. If not supplied set to UINT16_MAX value.*/
15 uint8_t id
; /*< Battery ID*/
16 uint8_t battery_function
; /*< Function of the battery*/
17 uint8_t type
; /*< Type (chemistry) of the battery*/
18 char serial_number
[16]; /*< Serial number in ASCII characters, 0 terminated. All 0: field not provided.*/
19 char device_name
[50]; /*< Static device name. Encode as manufacturer and product names separated using an underscore.*/
20 } mavlink_smart_battery_info_t
;
22 #define MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN 87
23 #define MAVLINK_MSG_ID_SMART_BATTERY_INFO_MIN_LEN 87
24 #define MAVLINK_MSG_ID_370_LEN 87
25 #define MAVLINK_MSG_ID_370_MIN_LEN 87
27 #define MAVLINK_MSG_ID_SMART_BATTERY_INFO_CRC 75
28 #define MAVLINK_MSG_ID_370_CRC 75
30 #define MAVLINK_MSG_SMART_BATTERY_INFO_FIELD_SERIAL_NUMBER_LEN 16
31 #define MAVLINK_MSG_SMART_BATTERY_INFO_FIELD_DEVICE_NAME_LEN 50
33 #if MAVLINK_COMMAND_24BIT
34 #define MAVLINK_MESSAGE_INFO_SMART_BATTERY_INFO { \
36 "SMART_BATTERY_INFO", \
38 { { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 18, offsetof(mavlink_smart_battery_info_t, id) }, \
39 { "battery_function", NULL, MAVLINK_TYPE_UINT8_T, 0, 19, offsetof(mavlink_smart_battery_info_t, battery_function) }, \
40 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_smart_battery_info_t, type) }, \
41 { "capacity_full_specification", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_smart_battery_info_t, capacity_full_specification) }, \
42 { "capacity_full", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_smart_battery_info_t, capacity_full) }, \
43 { "cycle_count", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_smart_battery_info_t, cycle_count) }, \
44 { "serial_number", NULL, MAVLINK_TYPE_CHAR, 16, 21, offsetof(mavlink_smart_battery_info_t, serial_number) }, \
45 { "device_name", NULL, MAVLINK_TYPE_CHAR, 50, 37, offsetof(mavlink_smart_battery_info_t, device_name) }, \
46 { "weight", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_smart_battery_info_t, weight) }, \
47 { "discharge_minimum_voltage", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_smart_battery_info_t, discharge_minimum_voltage) }, \
48 { "charging_minimum_voltage", NULL, MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_smart_battery_info_t, charging_minimum_voltage) }, \
49 { "resting_minimum_voltage", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_smart_battery_info_t, resting_minimum_voltage) }, \
53 #define MAVLINK_MESSAGE_INFO_SMART_BATTERY_INFO { \
54 "SMART_BATTERY_INFO", \
56 { { "id", NULL, MAVLINK_TYPE_UINT8_T, 0, 18, offsetof(mavlink_smart_battery_info_t, id) }, \
57 { "battery_function", NULL, MAVLINK_TYPE_UINT8_T, 0, 19, offsetof(mavlink_smart_battery_info_t, battery_function) }, \
58 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_smart_battery_info_t, type) }, \
59 { "capacity_full_specification", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_smart_battery_info_t, capacity_full_specification) }, \
60 { "capacity_full", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_smart_battery_info_t, capacity_full) }, \
61 { "cycle_count", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_smart_battery_info_t, cycle_count) }, \
62 { "serial_number", NULL, MAVLINK_TYPE_CHAR, 16, 21, offsetof(mavlink_smart_battery_info_t, serial_number) }, \
63 { "device_name", NULL, MAVLINK_TYPE_CHAR, 50, 37, offsetof(mavlink_smart_battery_info_t, device_name) }, \
64 { "weight", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_smart_battery_info_t, weight) }, \
65 { "discharge_minimum_voltage", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_smart_battery_info_t, discharge_minimum_voltage) }, \
66 { "charging_minimum_voltage", NULL, MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_smart_battery_info_t, charging_minimum_voltage) }, \
67 { "resting_minimum_voltage", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_smart_battery_info_t, resting_minimum_voltage) }, \
73 * @brief Pack a smart_battery_info message
74 * @param system_id ID of this system
75 * @param component_id ID of this component (e.g. 200 for IMU)
76 * @param msg The MAVLink message to compress the data into
78 * @param id Battery ID
79 * @param battery_function Function of the battery
80 * @param type Type (chemistry) of the battery
81 * @param capacity_full_specification [mAh] Capacity when full according to manufacturer, -1: field not provided.
82 * @param capacity_full [mAh] Capacity when full (accounting for battery degradation), -1: field not provided.
83 * @param cycle_count Charge/discharge cycle count. UINT16_MAX: field not provided.
84 * @param serial_number Serial number in ASCII characters, 0 terminated. All 0: field not provided.
85 * @param device_name Static device name. Encode as manufacturer and product names separated using an underscore.
86 * @param weight [g] Battery weight. 0: field not provided.
87 * @param discharge_minimum_voltage [mV] Minimum per-cell voltage when discharging. If not supplied set to UINT16_MAX value.
88 * @param charging_minimum_voltage [mV] Minimum per-cell voltage when charging. If not supplied set to UINT16_MAX value.
89 * @param resting_minimum_voltage [mV] Minimum per-cell voltage when resting. If not supplied set to UINT16_MAX value.
90 * @return length of the message in bytes (excluding serial stream start sign)
92 static inline uint16_t mavlink_msg_smart_battery_info_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
,
93 uint8_t id
, uint8_t battery_function
, uint8_t type
, int32_t capacity_full_specification
, int32_t capacity_full
, uint16_t cycle_count
, const char *serial_number
, const char *device_name
, uint16_t weight
, uint16_t discharge_minimum_voltage
, uint16_t charging_minimum_voltage
, uint16_t resting_minimum_voltage
)
95 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
96 char buf
[MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
];
97 _mav_put_int32_t(buf
, 0, capacity_full_specification
);
98 _mav_put_int32_t(buf
, 4, capacity_full
);
99 _mav_put_uint16_t(buf
, 8, cycle_count
);
100 _mav_put_uint16_t(buf
, 10, weight
);
101 _mav_put_uint16_t(buf
, 12, discharge_minimum_voltage
);
102 _mav_put_uint16_t(buf
, 14, charging_minimum_voltage
);
103 _mav_put_uint16_t(buf
, 16, resting_minimum_voltage
);
104 _mav_put_uint8_t(buf
, 18, id
);
105 _mav_put_uint8_t(buf
, 19, battery_function
);
106 _mav_put_uint8_t(buf
, 20, type
);
107 _mav_put_char_array(buf
, 21, serial_number
, 16);
108 _mav_put_char_array(buf
, 37, device_name
, 50);
109 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
);
111 mavlink_smart_battery_info_t packet
;
112 packet
.capacity_full_specification
= capacity_full_specification
;
113 packet
.capacity_full
= capacity_full
;
114 packet
.cycle_count
= cycle_count
;
115 packet
.weight
= weight
;
116 packet
.discharge_minimum_voltage
= discharge_minimum_voltage
;
117 packet
.charging_minimum_voltage
= charging_minimum_voltage
;
118 packet
.resting_minimum_voltage
= resting_minimum_voltage
;
120 packet
.battery_function
= battery_function
;
122 mav_array_memcpy(packet
.serial_number
, serial_number
, sizeof(char)*16);
123 mav_array_memcpy(packet
.device_name
, device_name
, sizeof(char)*50);
124 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
);
127 msg
->msgid
= MAVLINK_MSG_ID_SMART_BATTERY_INFO
;
128 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_MIN_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_CRC
);
132 * @brief Pack a smart_battery_info message on a channel
133 * @param system_id ID of this system
134 * @param component_id ID of this component (e.g. 200 for IMU)
135 * @param chan The MAVLink channel this message will be sent over
136 * @param msg The MAVLink message to compress the data into
137 * @param id Battery ID
138 * @param battery_function Function of the battery
139 * @param type Type (chemistry) of the battery
140 * @param capacity_full_specification [mAh] Capacity when full according to manufacturer, -1: field not provided.
141 * @param capacity_full [mAh] Capacity when full (accounting for battery degradation), -1: field not provided.
142 * @param cycle_count Charge/discharge cycle count. UINT16_MAX: field not provided.
143 * @param serial_number Serial number in ASCII characters, 0 terminated. All 0: field not provided.
144 * @param device_name Static device name. Encode as manufacturer and product names separated using an underscore.
145 * @param weight [g] Battery weight. 0: field not provided.
146 * @param discharge_minimum_voltage [mV] Minimum per-cell voltage when discharging. If not supplied set to UINT16_MAX value.
147 * @param charging_minimum_voltage [mV] Minimum per-cell voltage when charging. If not supplied set to UINT16_MAX value.
148 * @param resting_minimum_voltage [mV] Minimum per-cell voltage when resting. If not supplied set to UINT16_MAX value.
149 * @return length of the message in bytes (excluding serial stream start sign)
151 static inline uint16_t mavlink_msg_smart_battery_info_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
152 mavlink_message_t
* msg
,
153 uint8_t id
,uint8_t battery_function
,uint8_t type
,int32_t capacity_full_specification
,int32_t capacity_full
,uint16_t cycle_count
,const char *serial_number
,const char *device_name
,uint16_t weight
,uint16_t discharge_minimum_voltage
,uint16_t charging_minimum_voltage
,uint16_t resting_minimum_voltage
)
155 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
156 char buf
[MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
];
157 _mav_put_int32_t(buf
, 0, capacity_full_specification
);
158 _mav_put_int32_t(buf
, 4, capacity_full
);
159 _mav_put_uint16_t(buf
, 8, cycle_count
);
160 _mav_put_uint16_t(buf
, 10, weight
);
161 _mav_put_uint16_t(buf
, 12, discharge_minimum_voltage
);
162 _mav_put_uint16_t(buf
, 14, charging_minimum_voltage
);
163 _mav_put_uint16_t(buf
, 16, resting_minimum_voltage
);
164 _mav_put_uint8_t(buf
, 18, id
);
165 _mav_put_uint8_t(buf
, 19, battery_function
);
166 _mav_put_uint8_t(buf
, 20, type
);
167 _mav_put_char_array(buf
, 21, serial_number
, 16);
168 _mav_put_char_array(buf
, 37, device_name
, 50);
169 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
);
171 mavlink_smart_battery_info_t packet
;
172 packet
.capacity_full_specification
= capacity_full_specification
;
173 packet
.capacity_full
= capacity_full
;
174 packet
.cycle_count
= cycle_count
;
175 packet
.weight
= weight
;
176 packet
.discharge_minimum_voltage
= discharge_minimum_voltage
;
177 packet
.charging_minimum_voltage
= charging_minimum_voltage
;
178 packet
.resting_minimum_voltage
= resting_minimum_voltage
;
180 packet
.battery_function
= battery_function
;
182 mav_array_memcpy(packet
.serial_number
, serial_number
, sizeof(char)*16);
183 mav_array_memcpy(packet
.device_name
, device_name
, sizeof(char)*50);
184 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
);
187 msg
->msgid
= MAVLINK_MSG_ID_SMART_BATTERY_INFO
;
188 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_MIN_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_CRC
);
192 * @brief Encode a smart_battery_info struct
194 * @param system_id ID of this system
195 * @param component_id ID of this component (e.g. 200 for IMU)
196 * @param msg The MAVLink message to compress the data into
197 * @param smart_battery_info C-struct to read the message contents from
199 static inline uint16_t mavlink_msg_smart_battery_info_encode(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
, const mavlink_smart_battery_info_t
* smart_battery_info
)
201 return mavlink_msg_smart_battery_info_pack(system_id
, component_id
, msg
, smart_battery_info
->id
, smart_battery_info
->battery_function
, smart_battery_info
->type
, smart_battery_info
->capacity_full_specification
, smart_battery_info
->capacity_full
, smart_battery_info
->cycle_count
, smart_battery_info
->serial_number
, smart_battery_info
->device_name
, smart_battery_info
->weight
, smart_battery_info
->discharge_minimum_voltage
, smart_battery_info
->charging_minimum_voltage
, smart_battery_info
->resting_minimum_voltage
);
205 * @brief Encode a smart_battery_info struct on a channel
207 * @param system_id ID of this system
208 * @param component_id ID of this component (e.g. 200 for IMU)
209 * @param chan The MAVLink channel this message will be sent over
210 * @param msg The MAVLink message to compress the data into
211 * @param smart_battery_info C-struct to read the message contents from
213 static inline uint16_t mavlink_msg_smart_battery_info_encode_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
, mavlink_message_t
* msg
, const mavlink_smart_battery_info_t
* smart_battery_info
)
215 return mavlink_msg_smart_battery_info_pack_chan(system_id
, component_id
, chan
, msg
, smart_battery_info
->id
, smart_battery_info
->battery_function
, smart_battery_info
->type
, smart_battery_info
->capacity_full_specification
, smart_battery_info
->capacity_full
, smart_battery_info
->cycle_count
, smart_battery_info
->serial_number
, smart_battery_info
->device_name
, smart_battery_info
->weight
, smart_battery_info
->discharge_minimum_voltage
, smart_battery_info
->charging_minimum_voltage
, smart_battery_info
->resting_minimum_voltage
);
219 * @brief Send a smart_battery_info message
220 * @param chan MAVLink channel to send the message
222 * @param id Battery ID
223 * @param battery_function Function of the battery
224 * @param type Type (chemistry) of the battery
225 * @param capacity_full_specification [mAh] Capacity when full according to manufacturer, -1: field not provided.
226 * @param capacity_full [mAh] Capacity when full (accounting for battery degradation), -1: field not provided.
227 * @param cycle_count Charge/discharge cycle count. UINT16_MAX: field not provided.
228 * @param serial_number Serial number in ASCII characters, 0 terminated. All 0: field not provided.
229 * @param device_name Static device name. Encode as manufacturer and product names separated using an underscore.
230 * @param weight [g] Battery weight. 0: field not provided.
231 * @param discharge_minimum_voltage [mV] Minimum per-cell voltage when discharging. If not supplied set to UINT16_MAX value.
232 * @param charging_minimum_voltage [mV] Minimum per-cell voltage when charging. If not supplied set to UINT16_MAX value.
233 * @param resting_minimum_voltage [mV] Minimum per-cell voltage when resting. If not supplied set to UINT16_MAX value.
235 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
237 static inline void mavlink_msg_smart_battery_info_send(mavlink_channel_t chan
, uint8_t id
, uint8_t battery_function
, uint8_t type
, int32_t capacity_full_specification
, int32_t capacity_full
, uint16_t cycle_count
, const char *serial_number
, const char *device_name
, uint16_t weight
, uint16_t discharge_minimum_voltage
, uint16_t charging_minimum_voltage
, uint16_t resting_minimum_voltage
)
239 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
240 char buf
[MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
];
241 _mav_put_int32_t(buf
, 0, capacity_full_specification
);
242 _mav_put_int32_t(buf
, 4, capacity_full
);
243 _mav_put_uint16_t(buf
, 8, cycle_count
);
244 _mav_put_uint16_t(buf
, 10, weight
);
245 _mav_put_uint16_t(buf
, 12, discharge_minimum_voltage
);
246 _mav_put_uint16_t(buf
, 14, charging_minimum_voltage
);
247 _mav_put_uint16_t(buf
, 16, resting_minimum_voltage
);
248 _mav_put_uint8_t(buf
, 18, id
);
249 _mav_put_uint8_t(buf
, 19, battery_function
);
250 _mav_put_uint8_t(buf
, 20, type
);
251 _mav_put_char_array(buf
, 21, serial_number
, 16);
252 _mav_put_char_array(buf
, 37, device_name
, 50);
253 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SMART_BATTERY_INFO
, buf
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_MIN_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_CRC
);
255 mavlink_smart_battery_info_t packet
;
256 packet
.capacity_full_specification
= capacity_full_specification
;
257 packet
.capacity_full
= capacity_full
;
258 packet
.cycle_count
= cycle_count
;
259 packet
.weight
= weight
;
260 packet
.discharge_minimum_voltage
= discharge_minimum_voltage
;
261 packet
.charging_minimum_voltage
= charging_minimum_voltage
;
262 packet
.resting_minimum_voltage
= resting_minimum_voltage
;
264 packet
.battery_function
= battery_function
;
266 mav_array_memcpy(packet
.serial_number
, serial_number
, sizeof(char)*16);
267 mav_array_memcpy(packet
.device_name
, device_name
, sizeof(char)*50);
268 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SMART_BATTERY_INFO
, (const char *)&packet
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_MIN_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_CRC
);
273 * @brief Send a smart_battery_info message
274 * @param chan MAVLink channel to send the message
275 * @param struct The MAVLink struct to serialize
277 static inline void mavlink_msg_smart_battery_info_send_struct(mavlink_channel_t chan
, const mavlink_smart_battery_info_t
* smart_battery_info
)
279 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
280 mavlink_msg_smart_battery_info_send(chan
, smart_battery_info
->id
, smart_battery_info
->battery_function
, smart_battery_info
->type
, smart_battery_info
->capacity_full_specification
, smart_battery_info
->capacity_full
, smart_battery_info
->cycle_count
, smart_battery_info
->serial_number
, smart_battery_info
->device_name
, smart_battery_info
->weight
, smart_battery_info
->discharge_minimum_voltage
, smart_battery_info
->charging_minimum_voltage
, smart_battery_info
->resting_minimum_voltage
);
282 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SMART_BATTERY_INFO
, (const char *)smart_battery_info
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_MIN_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_CRC
);
286 #if MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN <= MAVLINK_MAX_PAYLOAD_LEN
288 This varient of _send() can be used to save stack space by re-using
289 memory from the receive buffer. The caller provides a
290 mavlink_message_t which is the size of a full mavlink message. This
291 is usually the receive buffer for the channel, and allows a reply to an
292 incoming message with minimum stack space usage.
294 static inline void mavlink_msg_smart_battery_info_send_buf(mavlink_message_t
*msgbuf
, mavlink_channel_t chan
, uint8_t id
, uint8_t battery_function
, uint8_t type
, int32_t capacity_full_specification
, int32_t capacity_full
, uint16_t cycle_count
, const char *serial_number
, const char *device_name
, uint16_t weight
, uint16_t discharge_minimum_voltage
, uint16_t charging_minimum_voltage
, uint16_t resting_minimum_voltage
)
296 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
297 char *buf
= (char *)msgbuf
;
298 _mav_put_int32_t(buf
, 0, capacity_full_specification
);
299 _mav_put_int32_t(buf
, 4, capacity_full
);
300 _mav_put_uint16_t(buf
, 8, cycle_count
);
301 _mav_put_uint16_t(buf
, 10, weight
);
302 _mav_put_uint16_t(buf
, 12, discharge_minimum_voltage
);
303 _mav_put_uint16_t(buf
, 14, charging_minimum_voltage
);
304 _mav_put_uint16_t(buf
, 16, resting_minimum_voltage
);
305 _mav_put_uint8_t(buf
, 18, id
);
306 _mav_put_uint8_t(buf
, 19, battery_function
);
307 _mav_put_uint8_t(buf
, 20, type
);
308 _mav_put_char_array(buf
, 21, serial_number
, 16);
309 _mav_put_char_array(buf
, 37, device_name
, 50);
310 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SMART_BATTERY_INFO
, buf
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_MIN_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_CRC
);
312 mavlink_smart_battery_info_t
*packet
= (mavlink_smart_battery_info_t
*)msgbuf
;
313 packet
->capacity_full_specification
= capacity_full_specification
;
314 packet
->capacity_full
= capacity_full
;
315 packet
->cycle_count
= cycle_count
;
316 packet
->weight
= weight
;
317 packet
->discharge_minimum_voltage
= discharge_minimum_voltage
;
318 packet
->charging_minimum_voltage
= charging_minimum_voltage
;
319 packet
->resting_minimum_voltage
= resting_minimum_voltage
;
321 packet
->battery_function
= battery_function
;
323 mav_array_memcpy(packet
->serial_number
, serial_number
, sizeof(char)*16);
324 mav_array_memcpy(packet
->device_name
, device_name
, sizeof(char)*50);
325 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_SMART_BATTERY_INFO
, (const char *)packet
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_MIN_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
, MAVLINK_MSG_ID_SMART_BATTERY_INFO_CRC
);
332 // MESSAGE SMART_BATTERY_INFO UNPACKING
336 * @brief Get field id from smart_battery_info message
340 static inline uint8_t mavlink_msg_smart_battery_info_get_id(const mavlink_message_t
* msg
)
342 return _MAV_RETURN_uint8_t(msg
, 18);
346 * @brief Get field battery_function from smart_battery_info message
348 * @return Function of the battery
350 static inline uint8_t mavlink_msg_smart_battery_info_get_battery_function(const mavlink_message_t
* msg
)
352 return _MAV_RETURN_uint8_t(msg
, 19);
356 * @brief Get field type from smart_battery_info message
358 * @return Type (chemistry) of the battery
360 static inline uint8_t mavlink_msg_smart_battery_info_get_type(const mavlink_message_t
* msg
)
362 return _MAV_RETURN_uint8_t(msg
, 20);
366 * @brief Get field capacity_full_specification from smart_battery_info message
368 * @return [mAh] Capacity when full according to manufacturer, -1: field not provided.
370 static inline int32_t mavlink_msg_smart_battery_info_get_capacity_full_specification(const mavlink_message_t
* msg
)
372 return _MAV_RETURN_int32_t(msg
, 0);
376 * @brief Get field capacity_full from smart_battery_info message
378 * @return [mAh] Capacity when full (accounting for battery degradation), -1: field not provided.
380 static inline int32_t mavlink_msg_smart_battery_info_get_capacity_full(const mavlink_message_t
* msg
)
382 return _MAV_RETURN_int32_t(msg
, 4);
386 * @brief Get field cycle_count from smart_battery_info message
388 * @return Charge/discharge cycle count. UINT16_MAX: field not provided.
390 static inline uint16_t mavlink_msg_smart_battery_info_get_cycle_count(const mavlink_message_t
* msg
)
392 return _MAV_RETURN_uint16_t(msg
, 8);
396 * @brief Get field serial_number from smart_battery_info message
398 * @return Serial number in ASCII characters, 0 terminated. All 0: field not provided.
400 static inline uint16_t mavlink_msg_smart_battery_info_get_serial_number(const mavlink_message_t
* msg
, char *serial_number
)
402 return _MAV_RETURN_char_array(msg
, serial_number
, 16, 21);
406 * @brief Get field device_name from smart_battery_info message
408 * @return Static device name. Encode as manufacturer and product names separated using an underscore.
410 static inline uint16_t mavlink_msg_smart_battery_info_get_device_name(const mavlink_message_t
* msg
, char *device_name
)
412 return _MAV_RETURN_char_array(msg
, device_name
, 50, 37);
416 * @brief Get field weight from smart_battery_info message
418 * @return [g] Battery weight. 0: field not provided.
420 static inline uint16_t mavlink_msg_smart_battery_info_get_weight(const mavlink_message_t
* msg
)
422 return _MAV_RETURN_uint16_t(msg
, 10);
426 * @brief Get field discharge_minimum_voltage from smart_battery_info message
428 * @return [mV] Minimum per-cell voltage when discharging. If not supplied set to UINT16_MAX value.
430 static inline uint16_t mavlink_msg_smart_battery_info_get_discharge_minimum_voltage(const mavlink_message_t
* msg
)
432 return _MAV_RETURN_uint16_t(msg
, 12);
436 * @brief Get field charging_minimum_voltage from smart_battery_info message
438 * @return [mV] Minimum per-cell voltage when charging. If not supplied set to UINT16_MAX value.
440 static inline uint16_t mavlink_msg_smart_battery_info_get_charging_minimum_voltage(const mavlink_message_t
* msg
)
442 return _MAV_RETURN_uint16_t(msg
, 14);
446 * @brief Get field resting_minimum_voltage from smart_battery_info message
448 * @return [mV] Minimum per-cell voltage when resting. If not supplied set to UINT16_MAX value.
450 static inline uint16_t mavlink_msg_smart_battery_info_get_resting_minimum_voltage(const mavlink_message_t
* msg
)
452 return _MAV_RETURN_uint16_t(msg
, 16);
456 * @brief Decode a smart_battery_info message into a struct
458 * @param msg The message to decode
459 * @param smart_battery_info C-struct to decode the message contents into
461 static inline void mavlink_msg_smart_battery_info_decode(const mavlink_message_t
* msg
, mavlink_smart_battery_info_t
* smart_battery_info
)
463 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
464 smart_battery_info
->capacity_full_specification
= mavlink_msg_smart_battery_info_get_capacity_full_specification(msg
);
465 smart_battery_info
->capacity_full
= mavlink_msg_smart_battery_info_get_capacity_full(msg
);
466 smart_battery_info
->cycle_count
= mavlink_msg_smart_battery_info_get_cycle_count(msg
);
467 smart_battery_info
->weight
= mavlink_msg_smart_battery_info_get_weight(msg
);
468 smart_battery_info
->discharge_minimum_voltage
= mavlink_msg_smart_battery_info_get_discharge_minimum_voltage(msg
);
469 smart_battery_info
->charging_minimum_voltage
= mavlink_msg_smart_battery_info_get_charging_minimum_voltage(msg
);
470 smart_battery_info
->resting_minimum_voltage
= mavlink_msg_smart_battery_info_get_resting_minimum_voltage(msg
);
471 smart_battery_info
->id
= mavlink_msg_smart_battery_info_get_id(msg
);
472 smart_battery_info
->battery_function
= mavlink_msg_smart_battery_info_get_battery_function(msg
);
473 smart_battery_info
->type
= mavlink_msg_smart_battery_info_get_type(msg
);
474 mavlink_msg_smart_battery_info_get_serial_number(msg
, smart_battery_info
->serial_number
);
475 mavlink_msg_smart_battery_info_get_device_name(msg
, smart_battery_info
->device_name
);
477 uint8_t len
= msg
->len
< MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
? msg
->len
: MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
;
478 memset(smart_battery_info
, 0, MAVLINK_MSG_ID_SMART_BATTERY_INFO_LEN
);
479 memcpy(smart_battery_info
, _MAV_PAYLOAD(msg
), len
);