47 lines
1.1 KiB
C
47 lines
1.1 KiB
C
// SkyLogic AeroAlign - Shared telemetry protocol
|
|
//
|
|
// Common ESP-NOW payload format shared by Master and all remote devices.
|
|
|
|
#ifndef TELEMETRY_PROTOCOL_H
|
|
#define TELEMETRY_PROTOCOL_H
|
|
|
|
#include <Arduino.h>
|
|
|
|
enum DeviceType : uint8_t {
|
|
DEVICE_TYPE_UNKNOWN = 0x00,
|
|
DEVICE_TYPE_IMU = 0x01,
|
|
DEVICE_TYPE_COG_SCALE = 0x02,
|
|
DEVICE_TYPE_HYBRID = 0x03,
|
|
};
|
|
|
|
inline const char* deviceTypeToString(DeviceType device_type) {
|
|
switch (device_type) {
|
|
case DEVICE_TYPE_IMU:
|
|
return "IMU";
|
|
case DEVICE_TYPE_COG_SCALE:
|
|
return "CoG Scale";
|
|
case DEVICE_TYPE_HYBRID:
|
|
return "Hybrid";
|
|
default:
|
|
return "Unknown";
|
|
}
|
|
}
|
|
|
|
// ESP-NOW packet structure shared across all node types.
|
|
// IMU nodes use pitch/roll/yaw normally.
|
|
// CoG Scale nodes map:
|
|
// pitch -> front support weight (g)
|
|
// roll -> rear support weight (g)
|
|
// yaw -> computed CoG position (mm)
|
|
struct __attribute__((packed)) ESPNowPacket {
|
|
uint8_t node_id;
|
|
uint8_t device_type;
|
|
float pitch;
|
|
float roll;
|
|
float yaw;
|
|
uint8_t battery;
|
|
uint8_t checksum;
|
|
};
|
|
|
|
#endif // TELEMETRY_PROTOCOL_H
|