ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
proto_v2.h File Reference

ACwing Pilot app protocol v2: identifiers and frame layouts. More...

#include <stdint.h>
#include <stddef.h>
Include dependency graph for proto_v2.h:
This graph shows which files directly or indirectly include this file:

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
 

Enumerations

enum  {
  PV2_ACK_OK = 0 , PV2_ACK_REJECTED = 1 , PV2_ACK_BUSY = 2 , PV2_ACK_INVALID = 3 ,
  PV2_ACK_UNSUPPORTED = 4 , PV2_ACK_IN_PROGRESS = 5
}
 
enum  {
  PV2_R_NONE = 0 , PV2_R_NOT_LANDED = 1 , PV2_R_CHECKS_FAILING = 2 , PV2_R_THROTTLE_NOT_LOW = 3 ,
  PV2_R_NO_GPS = 4 , PV2_R_BATTERY_LOW = 5 , PV2_R_NO_HOME = 6 , PV2_R_RADIO_OVERRIDE = 7 ,
  PV2_R_ARMED = 8 , PV2_R_PROPS_CONFIRM_MISSING = 9 , PV2_R_NOT_ARMED = 10 , PV2_R_CALIBRATING = 11 ,
  PV2_R_NOT_CALIBRATING = 12 , PV2_R_NOT_STILL = 13 , PV2_R_OUT_OF_RANGE = 14 , PV2_R_UNKNOWN_PARAM = 15 ,
  PV2_R_SENSOR_MISSING = 16 , PV2_R_USB_CONNECTED = 17 , PV2_R_NOT_OVER_USB = 18 , PV2_R_OTHER_LINK = 19
}
 
enum  { PV2_MODE_ACRO = 0 , PV2_MODE_ANGLE = 1 , PV2_MODE_ALT_HOLD = 2 , PV2_MODE_POS_HOLD = 3 }
 
enum  {
  PV2_AUTO_NONE = 0 , PV2_AUTO_TAKEOFF = 1 , PV2_AUTO_LAND = 2 , PV2_AUTO_RTH = 3 ,
  PV2_AUTO_HOLD = 4 , PV2_AUTO_FAILSAFE = 5
}
 
enum  { PV2_INPUT_NONE = 0 , PV2_INPUT_APP = 1 , PV2_INPUT_ELRS = 2 }
 
enum  { PV2_MODEL_INDOOR = 0 , PV2_MODEL_OUTDOOR = 1 }
 
enum  { PV2_FRAME_QUAD_X = 0 , PV2_FRAME_HEXA_X = 1 , PV2_FRAME_OCTO_X = 2 }
 
enum  { PV2_BATT_OK = 0 , PV2_BATT_LOW = 1 , PV2_BATT_CRITICAL = 2 , PV2_BATT_EMERGENCY = 3 }
 
enum  { PV2_EV_INFO = 0 , PV2_EV_WARN = 1 , PV2_EV_ERROR = 2 , PV2_EV_CRITICAL = 3 }
 
enum  {
  PV2_E_ARMED = 1 , PV2_E_DISARMED = 2 , PV2_E_TAKEOFF_STARTED = 3 , PV2_E_LANDED = 4 ,
  PV2_E_MODE_CHANGED = 5 , PV2_E_RTH_STARTED = 6 , PV2_E_HOME_SET = 7 , PV2_E_TAKEOFF_ABORTED = 8 ,
  PV2_E_FAILSAFE_APP_LINK = 20 , PV2_E_FAILSAFE_RADIO = 21 , PV2_E_FAILSAFE_BATTERY = 22 , PV2_E_GEOFENCE_BREACH = 23 ,
  PV2_E_GPS_LOST = 24 , PV2_E_FLOW_LOST = 25 , PV2_E_BATTERY_LOW = 30 , PV2_E_BATTERY_CRITICAL = 31 ,
  PV2_E_BATTERY_EMERGENCY = 32 , PV2_E_BATTERY_MONITOR_LOST = 33 , PV2_E_MAG_INTERFERENCE = 40 , PV2_E_HIGH_VIBRATION = 41 ,
  PV2_E_MOTOR_HOT = 42 , PV2_E_RADIO_OVERRIDE = 43 , PV2_E_CALIB_DONE = 50 , PV2_E_CALIB_FAILED = 51 ,
  PV2_E_PARAMS_SAVED = 60 , PV2_E_MOTOR_KILLED = 70
}
 
enum  {
  PV2_CAL_ACCEL = 1 , PV2_CAL_LEVEL = 2 , PV2_CAL_GYRO = 3 , PV2_CAL_COMPASS = 4 ,
  PV2_CAL_FLOW_TOF = 5 , PV2_CAL_BATTERY = 6 , PV2_CAL_MOTORS = 7 , PV2_CAL_STICKS = 8
}
 
enum  {
  PV2_CS_IDLE = 0 , PV2_CS_RUNNING = 1 , PV2_CS_WAITING_USER = 2 , PV2_CS_DONE = 3 ,
  PV2_CS_FAILED = 4 , PV2_CS_SAVED = 5
}
 
enum  {
  PV2_CHK_BATTERY = 1 , PV2_CHK_IMU = 2 , PV2_CHK_COMPASS = 3 , PV2_CHK_GNSS = 4 ,
  PV2_CHK_HOME = 5 , PV2_CHK_RADIO = 6 , PV2_CHK_EKF = 7 , PV2_CHK_FAILSAFE = 8 ,
  PV2_CHK_FLOW = 9 , PV2_CHK_THROTTLE = 10 , PV2_CHK_CALIBRATION = 11 , PV2_CHK_USB = 12
}
 
enum  { PV2_CK_OK = 0 , PV2_CK_WARN = 1 , PV2_CK_FAIL = 2 , PV2_CK_NA = 3 }
 

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)
 

Detailed Description

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.

Macro Definition Documentation

◆ PV2_PROTO_VERSION

#define PV2_PROTO_VERSION   2u

Definition at line 22 of file proto_v2.h.

◆ PV2_CMD_MAX_LEN

#define PV2_CMD_MAX_LEN   20u

Definition at line 23 of file proto_v2.h.

◆ PV2_FT_STATE

#define PV2_FT_STATE   0x01u

Definition at line 26 of file proto_v2.h.

◆ PV2_FT_INIT

#define PV2_FT_INIT   0x02u

Definition at line 27 of file proto_v2.h.

◆ PV2_FT_STATUS

#define PV2_FT_STATUS   0x03u

Definition at line 28 of file proto_v2.h.

◆ PV2_FT_REPLAY

#define PV2_FT_REPLAY   0x04u

Definition at line 29 of file proto_v2.h.

◆ PV2_FT_CAPS

#define PV2_FT_CAPS   0x05u

Definition at line 30 of file proto_v2.h.

◆ PV2_FT_FLIGHT

#define PV2_FT_FLIGHT   0x06u

Definition at line 31 of file proto_v2.h.

◆ PV2_FT_POWER

#define PV2_FT_POWER   0x07u

Definition at line 32 of file proto_v2.h.

◆ PV2_FT_NAV

#define PV2_FT_NAV   0x08u

Definition at line 33 of file proto_v2.h.

◆ PV2_FT_MOTORS

#define PV2_FT_MOTORS   0x09u

Definition at line 34 of file proto_v2.h.

◆ PV2_FT_SYSTEM

#define PV2_FT_SYSTEM   0x0Au

Definition at line 35 of file proto_v2.h.

◆ PV2_FT_EVENT

#define PV2_FT_EVENT   0x0Bu

Definition at line 36 of file proto_v2.h.

◆ PV2_FT_PARAM

#define PV2_FT_PARAM   0x0Cu

Definition at line 37 of file proto_v2.h.

◆ PV2_FT_CALIB

#define PV2_FT_CALIB   0x0Du

Definition at line 38 of file proto_v2.h.

◆ PV2_FT_ACK

#define PV2_FT_ACK   0x0Eu

Definition at line 39 of file proto_v2.h.

◆ PV2_FT_CHECKS

#define PV2_FT_CHECKS   0x0Fu

Definition at line 40 of file proto_v2.h.

◆ PV2_FT_LOG_ENTRY

#define PV2_FT_LOG_ENTRY   0x10u

answer to LOG_LIST, one per log

Definition at line 42 of file proto_v2.h.

◆ PV2_FT_LOG_DATA

#define PV2_FT_LOG_DATA   0x11u

answer to LOG_READ

Definition at line 43 of file proto_v2.h.

◆ PV2_FT_CMD

#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.

◆ PV2_OP_SEND_INIT

#define PV2_OP_SEND_INIT   0x01u

legacy [0x01]

Definition at line 47 of file proto_v2.h.

◆ PV2_OP_STATE_DECIM

#define PV2_OP_STATE_DECIM   0x02u

legacy [0x02, N]

Definition at line 48 of file proto_v2.h.

◆ PV2_OP_HEARTBEAT

#define PV2_OP_HEARTBEAT   0x10u

Definition at line 49 of file proto_v2.h.

◆ PV2_OP_RC

#define PV2_OP_RC   0x11u

Definition at line 50 of file proto_v2.h.

◆ PV2_OP_ARM

#define PV2_OP_ARM   0x12u

Definition at line 51 of file proto_v2.h.

◆ PV2_OP_DISARM

#define PV2_OP_DISARM   0x13u

Definition at line 52 of file proto_v2.h.

◆ PV2_OP_TAKEOFF

#define PV2_OP_TAKEOFF   0x14u

Definition at line 53 of file proto_v2.h.

◆ PV2_OP_LAND

#define PV2_OP_LAND   0x15u

Definition at line 54 of file proto_v2.h.

◆ PV2_OP_RTH

#define PV2_OP_RTH   0x16u

Definition at line 55 of file proto_v2.h.

◆ PV2_OP_HOLD

#define PV2_OP_HOLD   0x17u

Definition at line 56 of file proto_v2.h.

◆ PV2_OP_KILL

#define PV2_OP_KILL   0x18u

Definition at line 57 of file proto_v2.h.

◆ PV2_OP_SET_MODE

#define PV2_OP_SET_MODE   0x19u

Definition at line 58 of file proto_v2.h.

◆ PV2_OP_PARAM_GET

#define PV2_OP_PARAM_GET   0x20u

Definition at line 59 of file proto_v2.h.

◆ PV2_OP_PARAM_SET

#define PV2_OP_PARAM_SET   0x21u

Definition at line 60 of file proto_v2.h.

◆ PV2_OP_PARAM_SAVE

#define PV2_OP_PARAM_SAVE   0x22u

Definition at line 61 of file proto_v2.h.

◆ PV2_OP_PARAM_DEFAULTS

#define PV2_OP_PARAM_DEFAULTS   0x23u

Definition at line 62 of file proto_v2.h.

◆ PV2_OP_PARAM_LIST

#define PV2_OP_PARAM_LIST   0x24u

Definition at line 63 of file proto_v2.h.

◆ PV2_OP_CAL_START

#define PV2_OP_CAL_START   0x30u

Definition at line 64 of file proto_v2.h.

◆ PV2_OP_CAL_CAPTURE

#define PV2_OP_CAL_CAPTURE   0x31u

Definition at line 65 of file proto_v2.h.

◆ PV2_OP_CAL_ABORT

#define PV2_OP_CAL_ABORT   0x32u

Definition at line 66 of file proto_v2.h.

◆ PV2_OP_CAL_SAVE

#define PV2_OP_CAL_SAVE   0x33u

Definition at line 67 of file proto_v2.h.

◆ PV2_OP_CAL_RESTORE

#define PV2_OP_CAL_RESTORE   0x34u

Definition at line 68 of file proto_v2.h.

◆ PV2_OP_CAL_SET_REF

#define PV2_OP_CAL_SET_REF   0x35u

Definition at line 69 of file proto_v2.h.

◆ PV2_OP_MOTOR_TEST

#define PV2_OP_MOTOR_TEST   0x36u

Definition at line 70 of file proto_v2.h.

◆ PV2_OP_MOTOR_REVERSE

#define PV2_OP_MOTOR_REVERSE   0x37u

Definition at line 71 of file proto_v2.h.

◆ PV2_OP_MOTOR_REMAP

#define PV2_OP_MOTOR_REMAP   0x38u

Definition at line 72 of file proto_v2.h.

◆ PV2_OP_STREAM_RATES

#define PV2_OP_STREAM_RATES   0x40u

Definition at line 73 of file proto_v2.h.

◆ PV2_OP_REQUEST

#define PV2_OP_REQUEST   0x41u

Definition at line 74 of file proto_v2.h.

◆ PV2_OP_SET_NAME

#define PV2_OP_SET_NAME   0x42u

Definition at line 75 of file proto_v2.h.

◆ PV2_OP_SET_TIME

#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.

◆ PV2_OP_LOG_LIST

#define PV2_OP_LOG_LIST   0x50u

reserved in HANDOVER ยง16, USB link

Definition at line 77 of file proto_v2.h.

◆ PV2_OP_LOG_READ

#define PV2_OP_LOG_READ   0x51u

id u16, offset u32, len u32

Definition at line 78 of file proto_v2.h.

◆ PV2_OP_LOG_ERASE

#define PV2_OP_LOG_ERASE   0x52u

"WIPE" (firmware extension)

Definition at line 79 of file proto_v2.h.

◆ PV2_ARM_MAGIC0

#define PV2_ARM_MAGIC0   0xA5u

Definition at line 81 of file proto_v2.h.

◆ PV2_ARM_MAGIC1

#define PV2_ARM_MAGIC1   0x5Au

Definition at line 82 of file proto_v2.h.

◆ PV2_PROPS_OFF_MAGIC

#define PV2_PROPS_OFF_MAGIC   0x50u

'P'

Definition at line 83 of file proto_v2.h.

◆ PV2_FS_APP_LINK

#define PV2_FS_APP_LINK   (1u << 0)

Definition at line 107 of file proto_v2.h.

◆ PV2_FS_RADIO

#define PV2_FS_RADIO   (1u << 1)

Definition at line 108 of file proto_v2.h.

◆ PV2_FS_BATTERY

#define PV2_FS_BATTERY   (1u << 2)

Definition at line 109 of file proto_v2.h.

◆ PV2_FS_GEOFENCE

#define PV2_FS_GEOFENCE   (1u << 3)

Definition at line 110 of file proto_v2.h.

◆ PV2_FS_GPS

#define PV2_FS_GPS   (1u << 4)

Definition at line 111 of file proto_v2.h.

◆ PV2_FS_FLOW

#define PV2_FS_FLOW   (1u << 5)

Definition at line 112 of file proto_v2.h.

◆ PV2_FF_IN_AIR

#define PV2_FF_IN_AIR   (1u << 0)

Definition at line 114 of file proto_v2.h.

◆ PV2_FF_LANDED

#define PV2_FF_LANDED   (1u << 1)

Definition at line 115 of file proto_v2.h.

◆ PV2_FF_HOME_SET

#define PV2_FF_HOME_SET   (1u << 2)

Definition at line 116 of file proto_v2.h.

◆ PV2_FF_GEOFENCE_ON

#define PV2_FF_GEOFENCE_ON   (1u << 3)

Definition at line 117 of file proto_v2.h.

◆ PV2_FF_BEGINNER

#define PV2_FF_BEGINNER   (1u << 4)

Definition at line 118 of file proto_v2.h.

◆ PV2_FF_ARM_BLOCKED

#define PV2_FF_ARM_BLOCKED   (1u << 5)

Definition at line 119 of file proto_v2.h.

◆ PV2_S_IMU

#define PV2_S_IMU   (1u << 0)

Definition at line 121 of file proto_v2.h.

◆ PV2_S_BARO

#define PV2_S_BARO   (1u << 1)

Definition at line 122 of file proto_v2.h.

◆ PV2_S_MAG_FC

#define PV2_S_MAG_FC   (1u << 2)

Definition at line 123 of file proto_v2.h.

◆ PV2_S_MAG_GPS

#define PV2_S_MAG_GPS   (1u << 3)

Definition at line 124 of file proto_v2.h.

◆ PV2_S_GNSS

#define PV2_S_GNSS   (1u << 4)

Definition at line 125 of file proto_v2.h.

◆ PV2_S_FLOW

#define PV2_S_FLOW   (1u << 5)

Definition at line 126 of file proto_v2.h.

◆ PV2_S_TOF

#define PV2_S_TOF   (1u << 6)

Definition at line 127 of file proto_v2.h.

◆ PV2_S_ESC_TLM

#define PV2_S_ESC_TLM   (1u << 7)

Definition at line 128 of file proto_v2.h.

◆ PV2_S_CURRENT

#define PV2_S_CURRENT   (1u << 8)

Definition at line 129 of file proto_v2.h.

◆ PV2_S_ELRS

#define PV2_S_ELRS   (1u << 9)

Definition at line 130 of file proto_v2.h.

◆ PV2_S_LEDS

#define PV2_S_LEDS   (1u << 10)

Definition at line 131 of file proto_v2.h.

◆ PV2_S_FLASH_LOG

#define PV2_S_FLASH_LOG   (1u << 11)

Definition at line 132 of file proto_v2.h.

◆ PV2_LOG_DATA_MAX

#define PV2_LOG_DATA_MAX   240u

Definition at line 265 of file proto_v2.h.

◆ PV2_EVENT_TEXT_MAX

#define PV2_EVENT_TEXT_MAX   40u

Definition at line 314 of file proto_v2.h.

◆ PV2_CHECKS_MAX

#define PV2_CHECKS_MAX   12u

Definition at line 315 of file proto_v2.h.

◆ PV2_MOTORS_MAX

#define PV2_MOTORS_MAX   8u

Definition at line 316 of file proto_v2.h.

◆ PV2_PAYLOAD_MAX

#define PV2_PAYLOAD_MAX   (2u + 4u * PV2_CHECKS_MAX)

largest v2 payload: 50

Definition at line 317 of file proto_v2.h.

Enumeration Type Documentation

◆ anonymous enum

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

anonymous enum
Enumerator
PV2_R_NONE 
PV2_R_NOT_LANDED 
PV2_R_CHECKS_FAILING 
PV2_R_THROTTLE_NOT_LOW 
PV2_R_NO_GPS 
PV2_R_BATTERY_LOW 
PV2_R_NO_HOME 
PV2_R_RADIO_OVERRIDE 
PV2_R_ARMED 
PV2_R_PROPS_CONFIRM_MISSING 
PV2_R_NOT_ARMED 
PV2_R_CALIBRATING 
PV2_R_NOT_CALIBRATING 
PV2_R_NOT_STILL 
PV2_R_OUT_OF_RANGE 
PV2_R_UNKNOWN_PARAM 
PV2_R_SENSOR_MISSING 
PV2_R_USB_CONNECTED 

ARM / TAKEOFF / MOTOR_TEST while a USB host is connected (ADR 0009)

PV2_R_NOT_OVER_USB 

flight command received over the USB link: ground link only

PV2_R_OTHER_LINK 

configuration change from the link that does not have control

Definition at line 90 of file proto_v2.h.

◆ anonymous enum

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

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

anonymous enum
Enumerator
PV2_INPUT_NONE 
PV2_INPUT_APP 
PV2_INPUT_ELRS 

Definition at line 105 of file proto_v2.h.

◆ anonymous enum

anonymous enum
Enumerator
PV2_MODEL_INDOOR 
PV2_MODEL_OUTDOOR 

Definition at line 134 of file proto_v2.h.

◆ anonymous enum

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

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

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

anonymous enum
Enumerator
PV2_E_ARMED 
PV2_E_DISARMED 
PV2_E_TAKEOFF_STARTED 
PV2_E_LANDED 
PV2_E_MODE_CHANGED 
PV2_E_RTH_STARTED 
PV2_E_HOME_SET 
PV2_E_TAKEOFF_ABORTED 

firmware extension (WARN): no lift-off; the app shows the text

PV2_E_FAILSAFE_APP_LINK 
PV2_E_FAILSAFE_RADIO 
PV2_E_FAILSAFE_BATTERY 
PV2_E_GEOFENCE_BREACH 
PV2_E_GPS_LOST 
PV2_E_FLOW_LOST 
PV2_E_BATTERY_LOW 
PV2_E_BATTERY_CRITICAL 
PV2_E_BATTERY_EMERGENCY 
PV2_E_BATTERY_MONITOR_LOST 

firmware extension (ERROR): BattTask silent, battery unknown

PV2_E_MAG_INTERFERENCE 
PV2_E_HIGH_VIBRATION 
PV2_E_MOTOR_HOT 
PV2_E_RADIO_OVERRIDE 
PV2_E_CALIB_DONE 
PV2_E_CALIB_FAILED 
PV2_E_PARAMS_SAVED 
PV2_E_MOTOR_KILLED 

Definition at line 139 of file proto_v2.h.

◆ anonymous enum

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

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

anonymous enum
Enumerator
PV2_CHK_BATTERY 
PV2_CHK_IMU 
PV2_CHK_COMPASS 
PV2_CHK_GNSS 
PV2_CHK_HOME 
PV2_CHK_RADIO 
PV2_CHK_EKF 
PV2_CHK_FAILSAFE 
PV2_CHK_FLOW 
PV2_CHK_THROTTLE 
PV2_CHK_CALIBRATION 
PV2_CHK_USB 

FAIL while a USB host is connected: no ARM.

Definition at line 157 of file proto_v2.h.

◆ anonymous enum

anonymous enum
Enumerator
PV2_CK_OK 
PV2_CK_WARN 
PV2_CK_FAIL 
PV2_CK_NA 

Definition at line 161 of file proto_v2.h.

Function Documentation

◆ pv2_frame()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pv2_event()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pv2_ack()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pv2_param()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pv2_checks()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pv2_motors()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pv2_calib()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pv2_rd_u16()

static uint16_t pv2_rd_u16 ( const uint8_t *  p)
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().

Here is the caller graph for this function:

◆ pv2_rd_i16()

static int16_t pv2_rd_i16 ( const uint8_t *  p)
inlinestatic

Definition at line 330 of file proto_v2.h.

References pv2_rd_u16().

Referenced by appl_on_cmd_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pv2_rd_f32()

float pv2_rd_f32 ( const uint8_t *  p)

Definition at line 69 of file proto_v2.c.

Referenced by local_cmd().

Here is the caller graph for this function: