kopia lustrzana https://github.com/mikaelnousiainen/RS41ng
add balloon node info + more precise altitude
rodzic
5e298c4d1b
commit
b8c88c87a2
|
@ -31,6 +31,22 @@ static inline void cats_push_f16(cats_packet *p, float val)
|
|||
p->data[p->len++] = f16 >> 8;
|
||||
}
|
||||
|
||||
static inline void cats_push_f32(cats_packet *p, float val)
|
||||
{
|
||||
union {
|
||||
float f;
|
||||
uint32_t u;
|
||||
} fu = { .f = val };
|
||||
|
||||
assert(sizeof fu.f == sizeof fu.u);
|
||||
|
||||
uint32_t f32 = fu.u;
|
||||
p->data[p->len++] = f32;
|
||||
p->data[p->len++] = f32 >> 8;
|
||||
p->data[p->len++] = f32 >> 16;
|
||||
p->data[p->len++] = f32 >> 24;
|
||||
}
|
||||
|
||||
static inline void cats_push_u16(cats_packet *p, uint16_t val)
|
||||
{
|
||||
for(int i = 0; i < 2; i++) {
|
||||
|
@ -87,11 +103,14 @@ void cats_append_node_info_whisker(cats_packet *packet, telemetry_data *data)
|
|||
uint8_t *d = packet->data;
|
||||
size_t *l = &packet->len;
|
||||
|
||||
bool has_altitude = GPS_HAS_FIX(data->gps);
|
||||
float altitude = data->gps.altitude_mm / 1000.0;
|
||||
|
||||
d[(*l)++] = 0x09; // type = node info
|
||||
d[(*l)++] = 10; // len
|
||||
d[(*l)++] = has_altitude ? 14 : 10; // len
|
||||
// bitmask
|
||||
d[(*l)++] = 0;
|
||||
d[(*l)++] = 0;
|
||||
d[(*l)++] = (CATS_IS_BALLOON << 2) | (has_altitude << 1);
|
||||
d[(*l)++] = 0b11110011;
|
||||
|
||||
cats_push_u16(packet, HARDWARE_ID);
|
||||
|
@ -100,4 +119,7 @@ void cats_append_node_info_whisker(cats_packet *packet, telemetry_data *data)
|
|||
d[(*l)++] = CATS_REPORTED_TX_POWER_DBM * 4.0; // TX power
|
||||
d[(*l)++] = data->battery_voltage_millivolts / 100; // voltage
|
||||
d[(*l)++] = data->internal_temperature_celsius_100 / 100; // transmitter temperature
|
||||
if(has_altitude) {
|
||||
cats_push_f32(packet, altitude);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -346,6 +346,10 @@
|
|||
#define CATS_ICON 13 // Balloon. See the CATS standard for more options
|
||||
#define CATS_COMMENT "I am a radiosonde. Hear me meow!"
|
||||
#define CATS_REPORTED_TX_POWER_DBM 20
|
||||
// You probably want this to be true
|
||||
// Set to false if you're using your radiosonde for something other than a balloon payload
|
||||
// We don't want non-balloons showing up as balloons on FELINET!
|
||||
#define CATS_IS_BALLOON true
|
||||
|
||||
// Schedule transmission every N seconds, counting from beginning of an hour (based on GPS time). Set to zero to disable time sync.
|
||||
// See the README file for more detailed documentation about time sync and its offset setting
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
#define GPS_FIX_TIME_ONLY 5
|
||||
|
||||
#if GPS_REQUIRE_3D_FIX
|
||||
#define GPS_HAS_FIX(gps_data) (gps_data.fix_ok && (gps_data.fix == GPS_FIX_3D))
|
||||
#define GPS_HAS_FIX(gps_data) ((gps_data).fix_ok && ((gps_data).fix == GPS_FIX_3D))
|
||||
#else
|
||||
#define GPS_HAS_FIX(gps_data) (gps_data.fix_ok && (gps_data.fix == GPS_FIX_2D || gps_data.fix == GPS_FIX_3D))
|
||||
#define GPS_HAS_FIX(gps_data) ((gps_data).fix_ok && ((gps_data).fix == GPS_FIX_2D || (gps_data).fix == GPS_FIX_3D))
|
||||
#endif
|
||||
|
||||
typedef struct _gps_data {
|
||||
|
|
Ładowanie…
Reference in New Issue