/*
* Master Firmware: APRS
*
* Wireless Observational Modular Aerial Network
*
* Ethan Zonca
* Matthew Kanning
* Kyle Ripperger
* Matthew Kroening
*
*/
#include "../config.h"
#include "aprs.h"
#include "ax25.h"
#include "gps.h"
#include "sensordata.h"
#include <stdio.h>
float meters_to_feet(float m)
{
// 10000 ft = 3048 m
return m / 0.3048;
}
void aprs_send()
{
const struct s_address addresses[] = {
{D_CALLSIGN, D_CALLSIGN_ID}, // Destination callsign
{sysconfig->s_callsign, sysconfig->s_callsign_id}, // Source callsign (-11 = balloon, -9 = car)
#ifdef DIGI_PATH1
{DIGI_PATH1, DIGI_PATH1_TTL}, // Digi1 (first digi in the chain)
#endif
#ifdef DIGI_PATH2
{DIGI_PATH2, DIGI_PATH2_TTL}, // Digi2 (second digi in the chain)
#endif
};
// emz: modified this to get the size of the first address rather than the size of the struct itself, which fails
ax25_send_header(addresses, sizeof(addresses)/sizeof(addresses[0]));
ax25_send_byte('/'); // Report w/ timestamp, no APRS messaging. $ = NMEA raw data
// ax25_send_string("021709z"); // 021709z = 2nd day of the month, 17:09 zulu (UTC/GMT)
ax25_send_string(get_dayofmonth()); ///! Needs to be day hour minute // 170915 = 17h:09m:15s zulu (not allowed in Status Reports)
ax25_send_string(get_timestamp());
ax25_send_byte('z'); // zulu time. h for nonzulu
ax25_send_string(get_latitudeTrimmed()); // Lat: 38deg and 22.20 min (.20 are NOT seconds, but 1/100th of minutes)
ax25_send_byte('N');
ax25_send_byte('/'); // Symbol table
ax25_send_string(get_longitudeTrimmed()); // Lon: 000deg and 25.80 min
ax25_send_byte('W');
ax25_send_byte('O'); // Symbol: O=balloon, -=QTH
//snprintf(temp, 4, "%03d", (int)(get_course() + 0.5));
// !!!TODO: ENSURE THAT THE COURSE IS FORMATTED CORRECTLY!
ax25_send_string(get_course()); // Course (degrees)
ax25_send_byte('/'); // and
// !!!TODO: Check the speed!
//snprintf(temp, 4, "%03d", (int)(gps_speed + 0.5));
ax25_send_string(get_speedKnots()); // speed (knots)
/*
ax25_send_string("/A="); // Altitude (feet). Goes anywhere in the comment area
snprintf(temp, 7, "%06ld", (long)(meters_to_feet(gps_altitude) + 0.5));
ax25_send_string(temp);
ax25_send_string("/Ti=");
snprintf(temp, 6, "%d", 122);//sensors_int_lm60()); -- PUT SENSOR DATA HERE
ax25_send_string(temp);
ax25_send_string("/Te=");
snprintf(temp, 6, "%d", 123);//sensors_ext_lm60());
ax25_send_string(temp);
ax25_send_string("/V=");
snprintf(temp, 6, "%d", 123);//sensors_vin());
ax25_send_string(temp);
*/
ax25_send_byte(' ');
#define COMMENTBUFFER_SIZE 128
char commentBuffer[COMMENTBUFFER_SIZE];
ax25_send_string(slavesensors_getAPRScomment(commentBuffer, COMMENTBUFFER_SIZE));
ax25_send_footer();
ax25_flush_frame(); // Tell the modem to go
}