![]() |
ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
|
ACwing Pilot app protocol v2: identifiers and frame layouts. More...
#include <stdint.h>#include <stddef.h>Go to the source code of this file.
Data Structures | |
| struct | pv2_caps_t |
| struct | pv2_flight_t |
| struct | pv2_power_t |
| struct | pv2_nav_t |
| struct | pv2_motor_t |
| struct | pv2_system_t |
| struct | pv2_event_hdr_t |
| struct | pv2_param_t |
| struct | pv2_log_entry_t |
| struct | pv2_log_data_hdr_t |
| struct | pv2_calib_hdr_t |
| struct | pv2_cal_accel_t |
| struct | pv2_cal_level_t |
| struct | pv2_cal_gyro_t |
| struct | pv2_cal_compass_t |
| struct | pv2_cal_flow_t |
| struct | pv2_cal_battery_t |
| struct | pv2_cal_motors_t |
| struct | pv2_cal_sticks_t |
| struct | pv2_ack_t |
| struct | pv2_check_t |
Macros | |
| #define | PV2_PROTO_VERSION 2u |
| #define | PV2_CMD_MAX_LEN 20u |
| #define | PV2_FT_STATE 0x01u |
| #define | PV2_FT_INIT 0x02u |
| #define | PV2_FT_STATUS 0x03u |
| #define | PV2_FT_REPLAY 0x04u |
| #define | PV2_FT_CAPS 0x05u |
| #define | PV2_FT_FLIGHT 0x06u |
| #define | PV2_FT_POWER 0x07u |
| #define | PV2_FT_NAV 0x08u |
| #define | PV2_FT_MOTORS 0x09u |
| #define | PV2_FT_SYSTEM 0x0Au |
| #define | PV2_FT_EVENT 0x0Bu |
| #define | PV2_FT_PARAM 0x0Cu |
| #define | PV2_FT_CALIB 0x0Du |
| #define | PV2_FT_ACK 0x0Eu |
| #define | PV2_FT_CHECKS 0x0Fu |
| #define | PV2_FT_LOG_ENTRY 0x10u |
| answer to LOG_LIST, one per log | |
| #define | PV2_FT_LOG_DATA 0x11u |
| answer to LOG_READ | |
| #define | PV2_FT_CMD 0x20u |
| PC -> drone: payload = op, seq, args (as a BLE CMD write) | |
| #define | PV2_OP_SEND_INIT 0x01u |
| legacy [0x01] | |
| #define | PV2_OP_STATE_DECIM 0x02u |
| legacy [0x02, N] | |
| #define | PV2_OP_HEARTBEAT 0x10u |
| #define | PV2_OP_RC 0x11u |
| #define | PV2_OP_ARM 0x12u |
| #define | PV2_OP_DISARM 0x13u |
| #define | PV2_OP_TAKEOFF 0x14u |
| #define | PV2_OP_LAND 0x15u |
| #define | PV2_OP_RTH 0x16u |
| #define | PV2_OP_HOLD 0x17u |
| #define | PV2_OP_KILL 0x18u |
| #define | PV2_OP_SET_MODE 0x19u |
| #define | PV2_OP_PARAM_GET 0x20u |
| #define | PV2_OP_PARAM_SET 0x21u |
| #define | PV2_OP_PARAM_SAVE 0x22u |
| #define | PV2_OP_PARAM_DEFAULTS 0x23u |
| #define | PV2_OP_PARAM_LIST 0x24u |
| #define | PV2_OP_CAL_START 0x30u |
| #define | PV2_OP_CAL_CAPTURE 0x31u |
| #define | PV2_OP_CAL_ABORT 0x32u |
| #define | PV2_OP_CAL_SAVE 0x33u |
| #define | PV2_OP_CAL_RESTORE 0x34u |
| #define | PV2_OP_CAL_SET_REF 0x35u |
| #define | PV2_OP_MOTOR_TEST 0x36u |
| #define | PV2_OP_MOTOR_REVERSE 0x37u |
| #define | PV2_OP_MOTOR_REMAP 0x38u |
| #define | PV2_OP_STREAM_RATES 0x40u |
| #define | PV2_OP_REQUEST 0x41u |
| #define | PV2_OP_SET_NAME 0x42u |
| #define | PV2_OP_SET_TIME 0x43u |
| unix_s u32, ms u16, tz_min i16: wall clock for the log | |
| #define | PV2_OP_LOG_LIST 0x50u |
| reserved in HANDOVER ยง16, USB link | |
| #define | PV2_OP_LOG_READ 0x51u |
| id u16, offset u32, len u32 | |
| #define | PV2_OP_LOG_ERASE 0x52u |
| "WIPE" (firmware extension) | |
| #define | PV2_ARM_MAGIC0 0xA5u |
| #define | PV2_ARM_MAGIC1 0x5Au |
| #define | PV2_PROPS_OFF_MAGIC 0x50u |
| 'P' | |
| #define | PV2_FS_APP_LINK (1u << 0) |
| #define | PV2_FS_RADIO (1u << 1) |
| #define | PV2_FS_BATTERY (1u << 2) |
| #define | PV2_FS_GEOFENCE (1u << 3) |
| #define | PV2_FS_GPS (1u << 4) |
| #define | PV2_FS_FLOW (1u << 5) |
| #define | PV2_FF_IN_AIR (1u << 0) |
| #define | PV2_FF_LANDED (1u << 1) |
| #define | PV2_FF_HOME_SET (1u << 2) |
| #define | PV2_FF_GEOFENCE_ON (1u << 3) |
| #define | PV2_FF_BEGINNER (1u << 4) |
| #define | PV2_FF_ARM_BLOCKED (1u << 5) |
| #define | PV2_S_IMU (1u << 0) |
| #define | PV2_S_BARO (1u << 1) |
| #define | PV2_S_MAG_FC (1u << 2) |
| #define | PV2_S_MAG_GPS (1u << 3) |
| #define | PV2_S_GNSS (1u << 4) |
| #define | PV2_S_FLOW (1u << 5) |
| #define | PV2_S_TOF (1u << 6) |
| #define | PV2_S_ESC_TLM (1u << 7) |
| #define | PV2_S_CURRENT (1u << 8) |
| #define | PV2_S_ELRS (1u << 9) |
| #define | PV2_S_LEDS (1u << 10) |
| #define | PV2_S_FLASH_LOG (1u << 11) |
| #define | PV2_LOG_DATA_MAX 240u |
| #define | PV2_EVENT_TEXT_MAX 40u |
| #define | PV2_CHECKS_MAX 12u |
| #define | PV2_MOTORS_MAX 8u |
| #define | PV2_PAYLOAD_MAX (2u + 4u * PV2_CHECKS_MAX) |
| largest v2 payload: 50 | |
Functions | |
| size_t | pv2_frame (uint8_t type, const void *payload, uint8_t len, uint8_t *out, size_t cap) |
| size_t | pv2_event (uint8_t level, uint16_t code, int32_t arg, const char *text, uint8_t *out, size_t cap) |
| size_t | pv2_ack (uint8_t op, uint8_t seq, uint8_t result, uint8_t reason, uint8_t *out, size_t cap) |
| size_t | pv2_param (uint16_t id, float value, uint8_t flags, uint16_t index, uint16_t count, uint8_t *out, size_t cap) |
| size_t | pv2_checks (uint8_t ready, const pv2_check_t *items, uint8_t n, uint8_t *out, size_t cap) |
| size_t | pv2_motors (const pv2_motor_t *m, uint8_t n, uint8_t *out, size_t cap) |
| size_t | pv2_calib (const pv2_calib_hdr_t *h, const void *data, uint8_t data_len, uint8_t *out, size_t cap) |
| static uint16_t | pv2_rd_u16 (const uint8_t *p) |
| little-endian readers for command payloads (unaligned-safe) | |
| static int16_t | pv2_rd_i16 (const uint8_t *p) |
| float | pv2_rd_f32 (const uint8_t *p) |
ACwing Pilot app protocol v2: identifiers and frame layouts.
Contract: 02 - Tools/02 - App/HANDOVER_FW.md. Executable reference (wins over the text): 02 - Tools/02 - App/src/protocol/{ids,messages,commands}.ts. Every number below is the same as in ids.ts; every packed struct has the byte layout of the matching encodeX() in messages.ts (checked by _Static_assert here and by the host test against the app decoders).
v2 only ADDS frame types 0x05..0x0F and command opcodes >= 0x10: the phase-2 frames 0x01..0x04 and the legacy commands 0x01/0x02 are unchanged.
Host-testable: no HAL, no RTOS.
Definition in file proto_v2.h.
| #define PV2_PROTO_VERSION 2u |
Definition at line 22 of file proto_v2.h.
| #define PV2_CMD_MAX_LEN 20u |
Definition at line 23 of file proto_v2.h.
| #define PV2_FT_STATE 0x01u |
Definition at line 26 of file proto_v2.h.
| #define PV2_FT_INIT 0x02u |
Definition at line 27 of file proto_v2.h.
| #define PV2_FT_STATUS 0x03u |
Definition at line 28 of file proto_v2.h.
| #define PV2_FT_REPLAY 0x04u |
Definition at line 29 of file proto_v2.h.
| #define PV2_FT_CAPS 0x05u |
Definition at line 30 of file proto_v2.h.
| #define PV2_FT_FLIGHT 0x06u |
Definition at line 31 of file proto_v2.h.
| #define PV2_FT_POWER 0x07u |
Definition at line 32 of file proto_v2.h.
| #define PV2_FT_NAV 0x08u |
Definition at line 33 of file proto_v2.h.
| #define PV2_FT_MOTORS 0x09u |
Definition at line 34 of file proto_v2.h.
| #define PV2_FT_SYSTEM 0x0Au |
Definition at line 35 of file proto_v2.h.
| #define PV2_FT_EVENT 0x0Bu |
Definition at line 36 of file proto_v2.h.
| #define PV2_FT_PARAM 0x0Cu |
Definition at line 37 of file proto_v2.h.
| #define PV2_FT_CALIB 0x0Du |
Definition at line 38 of file proto_v2.h.
| #define PV2_FT_ACK 0x0Eu |
Definition at line 39 of file proto_v2.h.
| #define PV2_FT_CHECKS 0x0Fu |
Definition at line 40 of file proto_v2.h.
| #define PV2_FT_LOG_ENTRY 0x10u |
answer to LOG_LIST, one per log
Definition at line 42 of file proto_v2.h.
| #define PV2_FT_LOG_DATA 0x11u |
answer to LOG_READ
Definition at line 43 of file proto_v2.h.
| #define PV2_FT_CMD 0x20u |
PC -> drone: payload = op, seq, args (as a BLE CMD write)
Definition at line 44 of file proto_v2.h.
| #define PV2_OP_SEND_INIT 0x01u |
legacy [0x01]
Definition at line 47 of file proto_v2.h.
| #define PV2_OP_STATE_DECIM 0x02u |
legacy [0x02, N]
Definition at line 48 of file proto_v2.h.
| #define PV2_OP_HEARTBEAT 0x10u |
Definition at line 49 of file proto_v2.h.
| #define PV2_OP_RC 0x11u |
Definition at line 50 of file proto_v2.h.
| #define PV2_OP_ARM 0x12u |
Definition at line 51 of file proto_v2.h.
| #define PV2_OP_DISARM 0x13u |
Definition at line 52 of file proto_v2.h.
| #define PV2_OP_TAKEOFF 0x14u |
Definition at line 53 of file proto_v2.h.
| #define PV2_OP_LAND 0x15u |
Definition at line 54 of file proto_v2.h.
| #define PV2_OP_RTH 0x16u |
Definition at line 55 of file proto_v2.h.
| #define PV2_OP_HOLD 0x17u |
Definition at line 56 of file proto_v2.h.
| #define PV2_OP_KILL 0x18u |
Definition at line 57 of file proto_v2.h.
| #define PV2_OP_SET_MODE 0x19u |
Definition at line 58 of file proto_v2.h.
| #define PV2_OP_PARAM_GET 0x20u |
Definition at line 59 of file proto_v2.h.
| #define PV2_OP_PARAM_SET 0x21u |
Definition at line 60 of file proto_v2.h.
| #define PV2_OP_PARAM_SAVE 0x22u |
Definition at line 61 of file proto_v2.h.
| #define PV2_OP_PARAM_DEFAULTS 0x23u |
Definition at line 62 of file proto_v2.h.
| #define PV2_OP_PARAM_LIST 0x24u |
Definition at line 63 of file proto_v2.h.
| #define PV2_OP_CAL_START 0x30u |
Definition at line 64 of file proto_v2.h.
| #define PV2_OP_CAL_CAPTURE 0x31u |
Definition at line 65 of file proto_v2.h.
| #define PV2_OP_CAL_ABORT 0x32u |
Definition at line 66 of file proto_v2.h.
| #define PV2_OP_CAL_SAVE 0x33u |
Definition at line 67 of file proto_v2.h.
| #define PV2_OP_CAL_RESTORE 0x34u |
Definition at line 68 of file proto_v2.h.
| #define PV2_OP_CAL_SET_REF 0x35u |
Definition at line 69 of file proto_v2.h.
| #define PV2_OP_MOTOR_TEST 0x36u |
Definition at line 70 of file proto_v2.h.
| #define PV2_OP_MOTOR_REVERSE 0x37u |
Definition at line 71 of file proto_v2.h.
| #define PV2_OP_MOTOR_REMAP 0x38u |
Definition at line 72 of file proto_v2.h.
| #define PV2_OP_STREAM_RATES 0x40u |
Definition at line 73 of file proto_v2.h.
| #define PV2_OP_REQUEST 0x41u |
Definition at line 74 of file proto_v2.h.
| #define PV2_OP_SET_NAME 0x42u |
Definition at line 75 of file proto_v2.h.
| #define PV2_OP_SET_TIME 0x43u |
unix_s u32, ms u16, tz_min i16: wall clock for the log
Definition at line 76 of file proto_v2.h.
| #define PV2_OP_LOG_LIST 0x50u |
reserved in HANDOVER ยง16, USB link
Definition at line 77 of file proto_v2.h.
| #define PV2_OP_LOG_READ 0x51u |
id u16, offset u32, len u32
Definition at line 78 of file proto_v2.h.
| #define PV2_OP_LOG_ERASE 0x52u |
"WIPE" (firmware extension)
Definition at line 79 of file proto_v2.h.
| #define PV2_ARM_MAGIC0 0xA5u |
Definition at line 81 of file proto_v2.h.
| #define PV2_ARM_MAGIC1 0x5Au |
Definition at line 82 of file proto_v2.h.
| #define PV2_PROPS_OFF_MAGIC 0x50u |
'P'
Definition at line 83 of file proto_v2.h.
| #define PV2_FS_APP_LINK (1u << 0) |
Definition at line 107 of file proto_v2.h.
| #define PV2_FS_RADIO (1u << 1) |
Definition at line 108 of file proto_v2.h.
| #define PV2_FS_BATTERY (1u << 2) |
Definition at line 109 of file proto_v2.h.
| #define PV2_FS_GEOFENCE (1u << 3) |
Definition at line 110 of file proto_v2.h.
| #define PV2_FS_GPS (1u << 4) |
Definition at line 111 of file proto_v2.h.
| #define PV2_FS_FLOW (1u << 5) |
Definition at line 112 of file proto_v2.h.
| #define PV2_FF_IN_AIR (1u << 0) |
Definition at line 114 of file proto_v2.h.
| #define PV2_FF_LANDED (1u << 1) |
Definition at line 115 of file proto_v2.h.
| #define PV2_FF_HOME_SET (1u << 2) |
Definition at line 116 of file proto_v2.h.
| #define PV2_FF_GEOFENCE_ON (1u << 3) |
Definition at line 117 of file proto_v2.h.
| #define PV2_FF_BEGINNER (1u << 4) |
Definition at line 118 of file proto_v2.h.
| #define PV2_FF_ARM_BLOCKED (1u << 5) |
Definition at line 119 of file proto_v2.h.
| #define PV2_S_IMU (1u << 0) |
Definition at line 121 of file proto_v2.h.
| #define PV2_S_BARO (1u << 1) |
Definition at line 122 of file proto_v2.h.
| #define PV2_S_MAG_FC (1u << 2) |
Definition at line 123 of file proto_v2.h.
| #define PV2_S_MAG_GPS (1u << 3) |
Definition at line 124 of file proto_v2.h.
| #define PV2_S_GNSS (1u << 4) |
Definition at line 125 of file proto_v2.h.
| #define PV2_S_FLOW (1u << 5) |
Definition at line 126 of file proto_v2.h.
| #define PV2_S_TOF (1u << 6) |
Definition at line 127 of file proto_v2.h.
| #define PV2_S_ESC_TLM (1u << 7) |
Definition at line 128 of file proto_v2.h.
| #define PV2_S_CURRENT (1u << 8) |
Definition at line 129 of file proto_v2.h.
| #define PV2_S_ELRS (1u << 9) |
Definition at line 130 of file proto_v2.h.
| #define PV2_S_LEDS (1u << 10) |
Definition at line 131 of file proto_v2.h.
| #define PV2_S_FLASH_LOG (1u << 11) |
Definition at line 132 of file proto_v2.h.
| #define PV2_LOG_DATA_MAX 240u |
Definition at line 265 of file proto_v2.h.
| #define PV2_EVENT_TEXT_MAX 40u |
Definition at line 314 of file proto_v2.h.
| #define PV2_CHECKS_MAX 12u |
Definition at line 315 of file proto_v2.h.
| #define PV2_MOTORS_MAX 8u |
Definition at line 316 of file proto_v2.h.
| #define PV2_PAYLOAD_MAX (2u + 4u * PV2_CHECKS_MAX) |
largest v2 payload: 50
Definition at line 317 of file proto_v2.h.
| anonymous enum |
| Enumerator | |
|---|---|
| PV2_ACK_OK | |
| PV2_ACK_REJECTED | |
| PV2_ACK_BUSY | |
| PV2_ACK_INVALID | |
| PV2_ACK_UNSUPPORTED | |
| PV2_ACK_IN_PROGRESS | |
Definition at line 87 of file proto_v2.h.
| anonymous enum |
Definition at line 90 of file proto_v2.h.
| anonymous enum |
| Enumerator | |
|---|---|
| PV2_MODE_ACRO | |
| PV2_MODE_ANGLE | |
| PV2_MODE_ALT_HOLD | |
| PV2_MODE_POS_HOLD | |
Definition at line 102 of file proto_v2.h.
| anonymous enum |
| Enumerator | |
|---|---|
| PV2_AUTO_NONE | |
| PV2_AUTO_TAKEOFF | |
| PV2_AUTO_LAND | |
| PV2_AUTO_RTH | |
| PV2_AUTO_HOLD | |
| PV2_AUTO_FAILSAFE | |
Definition at line 103 of file proto_v2.h.
| anonymous enum |
| Enumerator | |
|---|---|
| PV2_INPUT_NONE | |
| PV2_INPUT_APP | |
| PV2_INPUT_ELRS | |
Definition at line 105 of file proto_v2.h.
| anonymous enum |
| Enumerator | |
|---|---|
| PV2_MODEL_INDOOR | |
| PV2_MODEL_OUTDOOR | |
Definition at line 134 of file proto_v2.h.
| anonymous enum |
| Enumerator | |
|---|---|
| PV2_FRAME_QUAD_X | |
| PV2_FRAME_HEXA_X | |
| PV2_FRAME_OCTO_X | |
Definition at line 135 of file proto_v2.h.
| anonymous enum |
| Enumerator | |
|---|---|
| PV2_BATT_OK | |
| PV2_BATT_LOW | |
| PV2_BATT_CRITICAL | |
| PV2_BATT_EMERGENCY | |
Definition at line 136 of file proto_v2.h.
| anonymous enum |
| Enumerator | |
|---|---|
| PV2_EV_INFO | |
| PV2_EV_WARN | |
| PV2_EV_ERROR | |
| PV2_EV_CRITICAL | |
Definition at line 137 of file proto_v2.h.
| anonymous enum |
Definition at line 139 of file proto_v2.h.
| anonymous enum |
| Enumerator | |
|---|---|
| PV2_CAL_ACCEL | |
| PV2_CAL_LEVEL | |
| PV2_CAL_GYRO | |
| PV2_CAL_COMPASS | |
| PV2_CAL_FLOW_TOF | |
| PV2_CAL_BATTERY | |
| PV2_CAL_MOTORS | |
| PV2_CAL_STICKS | |
Definition at line 152 of file proto_v2.h.
| anonymous enum |
| Enumerator | |
|---|---|
| PV2_CS_IDLE | |
| PV2_CS_RUNNING | |
| PV2_CS_WAITING_USER | |
| PV2_CS_DONE | |
| PV2_CS_FAILED | |
| PV2_CS_SAVED | |
Definition at line 154 of file proto_v2.h.
| anonymous enum |
Definition at line 157 of file proto_v2.h.
| anonymous enum |
| Enumerator | |
|---|---|
| PV2_CK_OK | |
| PV2_CK_WARN | |
| PV2_CK_FAIL | |
| PV2_CK_NA | |
Definition at line 161 of file proto_v2.h.
| size_t pv2_frame | ( | uint8_t | type, |
| const void * | payload, | ||
| uint8_t | len, | ||
| uint8_t * | out, | ||
| size_t | cap | ||
| ) |
Definition at line 9 of file proto_v2.c.
References cap, and tlm_encode().
Referenced by log_ble_out(), pv2_ack(), pv2_calib(), pv2_checks(), pv2_event(), pv2_motors(), pv2_param(), send_caps(), send_flight(), send_nav(), send_power(), send_system(), and usbl_send_src().
| size_t pv2_event | ( | uint8_t | level, |
| uint16_t | code, | ||
| int32_t | arg, | ||
| const char * | text, | ||
| uint8_t * | out, | ||
| size_t | cap | ||
| ) |
Definition at line 14 of file proto_v2.c.
References pv2_event_hdr_t::arg, cap, pv2_event_hdr_t::code, pv2_event_hdr_t::len, pv2_event_hdr_t::level, n, PV2_EVENT_TEXT_MAX, pv2_frame(), and PV2_FT_EVENT.
Referenced by send_event().
| size_t pv2_ack | ( | uint8_t | op, |
| uint8_t | seq, | ||
| uint8_t | result, | ||
| uint8_t | reason, | ||
| uint8_t * | out, | ||
| size_t | cap | ||
| ) |
Definition at line 26 of file proto_v2.c.
References cap, pv2_frame(), PV2_FT_ACK, result(), and seq.
Referenced by ack_link().
| size_t pv2_param | ( | uint16_t | id, |
| float | value, | ||
| uint8_t | flags, | ||
| uint16_t | index, | ||
| uint16_t | count, | ||
| uint8_t * | out, | ||
| size_t | cap | ||
| ) |
Definition at line 32 of file proto_v2.c.
References cap, pv2_param_t::count, pv2_param_t::flags, id, pv2_param_t::id, pv2_param_t::index, pv2_frame(), PV2_FT_PARAM, and pv2_param_t::value.
Referenced by send_param().
| size_t pv2_checks | ( | uint8_t | ready, |
| const pv2_check_t * | items, | ||
| uint8_t | n, | ||
| uint8_t * | out, | ||
| size_t | cap | ||
| ) |
Definition at line 41 of file proto_v2.c.
References cap, n, PV2_CHECKS_MAX, pv2_frame(), and PV2_FT_CHECKS.
Referenced by send_checks().
| size_t pv2_motors | ( | const pv2_motor_t * | m, |
| uint8_t | n, | ||
| uint8_t * | out, | ||
| size_t | cap | ||
| ) |
Definition at line 51 of file proto_v2.c.
References cap, n, pv2_frame(), PV2_FT_MOTORS, and PV2_MOTORS_MAX.
Referenced by send_motors().
| size_t pv2_calib | ( | const pv2_calib_hdr_t * | h, |
| const void * | data, | ||
| uint8_t | data_len, | ||
| uint8_t * | out, | ||
| size_t | cap | ||
| ) |
Definition at line 60 of file proto_v2.c.
References cap, pv2_frame(), and PV2_FT_CALIB.
Referenced by cal_frame().
|
inlinestatic |
little-endian readers for command payloads (unaligned-safe)
Definition at line 329 of file proto_v2.h.
Referenced by exec(), local_cmd(), and pv2_rd_i16().
|
inlinestatic |
Definition at line 330 of file proto_v2.h.
References pv2_rd_u16().
Referenced by appl_on_cmd_write().
| float pv2_rd_f32 | ( | const uint8_t * | p | ) |
Definition at line 69 of file proto_v2.c.
Referenced by local_cmd().