133 lines
3.2 KiB
C
133 lines
3.2 KiB
C
#ifndef PACKETS_STRUCTS
|
|
#define PACKETS_STRUCTS
|
|
#include "stdint.h"
|
|
|
|
#define UplinkSync "PlechHore"
|
|
#define DownlinkSync "PlechDole"
|
|
|
|
#define UplinkPacketType_SystemControl 0
|
|
#define UplinkPacketType_Ping 1
|
|
#define UplinkPacketType_ACK 255
|
|
|
|
#define DownlinkPacketType_Telemetry 0
|
|
#define DownlinkPacketType_Ping 1
|
|
#define DownlinkPacketType_ACK 255
|
|
|
|
#define BME680_PRESENT_BIT (1 << 0)
|
|
#define CCS811_PRESENT_BIT (1 << 1)
|
|
#define MPU9250_PRESENT_BIT (1 << 2)
|
|
#define INA260_PRESENT_BIT (1 << 3)
|
|
#define MCP23018_PRESENT_BIT (1 << 4)
|
|
|
|
typedef struct __attribute__((packed))
|
|
{
|
|
char syncPhrase[10];
|
|
uint32_t packetIndex;
|
|
uint8_t packetType;
|
|
uint64_t missionTimer;
|
|
uint32_t CRCCheck;
|
|
} DownBoundPacket;
|
|
|
|
typedef struct __attribute__((packed))
|
|
{
|
|
// MPU data
|
|
int16_t accelerationX;
|
|
int16_t accelerationY;
|
|
int16_t accelerationZ;
|
|
int16_t gyroX;
|
|
int16_t gyroY;
|
|
int16_t gyroZ;
|
|
int16_t magnetX;
|
|
int16_t magnetY;
|
|
int16_t magnetZ;
|
|
int16_t accelerometer_temperature;
|
|
|
|
// CCS data
|
|
uint16_t eCO2;
|
|
uint16_t tvoc;
|
|
uint8_t currentCCS;
|
|
uint16_t rawCCSData;
|
|
|
|
// INA data
|
|
uint16_t volts;
|
|
uint16_t current;
|
|
uint16_t power;
|
|
|
|
// BME DATA
|
|
uint32_t temperature;
|
|
uint16_t humidity;
|
|
uint32_t pressure;
|
|
uint16_t gas;
|
|
bool gas_valid;
|
|
bool heater_stable;
|
|
uint8_t gas_range;
|
|
uint8_t gas_index;
|
|
|
|
float air_temperature; /*!< air temperature in degrees celsius */
|
|
float relative_humidity; /*!< relative humidity in percent */
|
|
float barometric_pressure; /*!< barometric pressure in hecto-pascal */
|
|
float gas_resistance; /*!< gas resistance in ohms */
|
|
uint16_t iaq_score; /*!< air quality index (0..500) */
|
|
float temperature_score;
|
|
float humidity_score;
|
|
float gas_score;
|
|
|
|
// GPS DATA
|
|
uint32_t time_seconds; // Seconds since start of day
|
|
int32_t latitude_centi_degrees; // Latitude * 10,000
|
|
int32_t longitude_centi_degrees; // Longitude * 10,000
|
|
int16_t altitude_centi_meters; // Altitude * 100
|
|
uint8_t fix_quality;
|
|
uint8_t num_satellites;
|
|
uint16_t date_yyddmm; // YYDDMM (from GPRMC)
|
|
uint16_t speed_centi_knots; // Speed * 100 (from GPRMC)
|
|
|
|
int32_t predicted_latitude_centi_degrees; // Latitude * 10,000
|
|
int32_t predicted_longitude_centi_degrees; // Longitude * 10,000
|
|
int16_t predicted_altitude_centi_meters; // Altitude * 100
|
|
|
|
// ADC DATA
|
|
int32_t NH3;
|
|
int32_t CO;
|
|
int32_t NO2;
|
|
int32_t UVC;
|
|
|
|
int16_t currentServoA;
|
|
int16_t targetServoA;
|
|
int16_t currentServoB;
|
|
int16_t targetServoB;
|
|
|
|
uint8_t presentDevices;
|
|
|
|
uint8_t telemetryIndex;
|
|
|
|
} TelemetryPacket;
|
|
|
|
typedef struct __attribute__((packed))
|
|
{
|
|
char syncPhrase[10];
|
|
uint32_t packetIndex;
|
|
uint8_t packetType;
|
|
uint32_t CRCCheck;
|
|
} UplinkPacket;
|
|
|
|
typedef struct __attribute__((packed))
|
|
{
|
|
uint8_t powerMode;
|
|
uint8_t controlMode;
|
|
uint16_t servoA;
|
|
uint16_t servoB;
|
|
} SystemControlPacket;
|
|
|
|
typedef struct __attribute__((packed))
|
|
{
|
|
uint8_t PingData[20];
|
|
} PingPacket;
|
|
|
|
typedef struct __attribute__((packed))
|
|
{
|
|
uint32_t packetIndex;
|
|
uint32_t crc32Checksum;
|
|
} ACKPacket;
|
|
|
|
#endif |