Files @ 041562172b4a
Branch filter:

Location: windsonde/Libraries/aprs/aprs.c

ethanzonca
Doubleinit radio for guaranteed init; GPS fixes
/*
 * FeatherHAB 
 *
 * This file is part of FeatherHAB.
 *
 * FeatherHab is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * FeatherHab is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with FeatherHAB. If not, see <http://www.gnu.org/licenses/>.
 * 
 * Ethan Zonca
 *
 */

#include <string.h>
#include <stdlib.h>

#include "config.h"
#include "pressure.h"
#include "aprs.h"
#include "gps.h"
//#include "gps.h"
//#include "adc.h"
#include "ax25.h"
#include "system/adc.h"


int32_t meters_to_feet(int32_t m)
{
  // 10000 ft = 3048 m
  return (float)m / 0.3048;
}

void aprs_send(void)
{
  struct s_address addresses[] = { 
    {D_CALLSIGN, D_CALLSIGN_ID},  // Destination callsign
    {"", S_CALLSIGN_ID},  // Source callsign (-11 = balloon, -9 = car)
		//{S_CALLSIGN, S_CALLSIGN_ID},
#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
  };

  strncpy(addresses[1].callsign, S_CALLSIGN, 7);
  
  // 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(',');

  char tmpBuffer[128];
  tmpBuffer[0] = ',';
  tmpBuffer[1] = '\0';

  // Latitude
  snprintf(tmpBuffer, 128, "%ld,", gps_getdata()->latitude);
  ax25_send_string(tmpBuffer);
  
  // Longitude
  snprintf(tmpBuffer, 128, "%ld,", gps_getdata()->longitude);
  ax25_send_string(tmpBuffer);

  // Speed
  snprintf(tmpBuffer, 128, "%d,", gps_getdata()->speed);
  ax25_send_string(tmpBuffer);

  // Altitude
  snprintf(tmpBuffer, 128, "%d,", gps_getdata()->altitude);
  ax25_send_string(tmpBuffer);

  // Pressure
  snprintf(tmpBuffer, 128, "%d,", pressure_getpressure());
  ax25_send_string(tmpBuffer);
  
  // Temperature
  snprintf(tmpBuffer, 128, "%d,", pressure_gettemp());
  ax25_send_string(tmpBuffer);

  // HDOP
  snprintf(tmpBuffer, 128, "%u,", gps_getdata()->pdop);
  ax25_send_string(tmpBuffer);

  // Heading
  snprintf(tmpBuffer, 128, "%u,", gps_getdata()->heading);
  ax25_send_string(tmpBuffer);

  // Vbatt
  snprintf(tmpBuffer, 128, "%u,", adc_get_vbatt());
  ax25_send_string(tmpBuffer);

  ax25_send_footer();
  ax25_flush_frame();
}

// vim:softtabstop=4 shiftwidth=4 expandtab