Changeset - 55d6f1467ce4
[Not reviewed]
default
0 3 0
Ethan Zonca (ethanzonca) - 9 years ago 2017-02-01 13:58:59
e@ethanzonca.com
Add friendly mode and associated timeout
3 files changed with 31 insertions and 7 deletions:
0 comments (0 inline, 0 general)
Include/config.h
Show inline comments
 
@@ -2,35 +2,40 @@
 
// Depth Select Configuration
 
//
 
 
#ifndef CONFIG_H
 
#define CONFIG_H
 
 
 
// --------------------------------------------------------------------------
 
// Transmitter config (si446x.c)
 
// --------------------------------------------------------------------------
 
 
// Transmit power (0-0x7F, 0mW - 40mw?)
 
#define SI446x_POWER 0x02
 
#define SI446x_POWER 0x40 // 0x40 for jake launch
 
 
#define TUNE_FREQUENCY 433500000UL
 
 
 
// Internal macros
 
#define hal_init HAL_Init
 
 
 
// Uncomment if using legacy LPS25h pressure sensor
 
//#define LPS25H
 
#define LPS25H
 
 
 
#define FRIENDLY_MODE
 
#define FRIENDLY_TIMEOUT  1800 // 1800 // seconds before reducing tx rate
 
#define FRIENDLY_TX_RATE 60000 // milliseconds tx rate after timeout elapsed
 
 
// --------------------------------------------------------------------------
 
// ADC config (adc.c)
 
// --------------------------------------------------------------------------
 
 
// Temperature sensor offset (die temperature from ambient, esimate, in Celcius)
 
#define ADC_TEMPERATURE_OFFSET -10
 
 
 
// --------------------------------------------------------------------------
 
// AX.25 config (ax25.c)
 
// --------------------------------------------------------------------------
Libraries/aprs/aprs.c
Show inline comments
 
@@ -52,29 +52,36 @@ void aprs_send(void)
 
#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';
 

	
 
  #ifdef FRIENDLY_MODE
 
    if(HAL_GetTick() > 1000 * FRIENDLY_TIMEOUT)
 
    {
 
	  snprintf(tmpBuffer, 128, "KD8TDF");
 
	  ax25_send_string(tmpBuffer);
 
    }
 
  #endif
 

	
 
  ax25_send_byte(',');
 

	
 
  // 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);
Source/main.c
Show inline comments
 
@@ -55,43 +55,55 @@ int main(void)
 
  gps_poweron();
 
 
  #ifdef LPS25H
 
    lps25h_init();
 
  #else
 
    bme280_init();
 
  #endif
 
 
  // Software timers
 
  uint32_t last_transmission = HAL_GetTick();
 
  uint32_t last_led = HAL_GetTick();
 
 
  uint32_t transmission_rate = 700;
 
  uint32_t is_friendly = 0;
 
 
  while (1)
 
  {
 
	  // Blink LEDs
 
	  if(HAL_GetTick() - last_transmission > 700)
 
	  #ifdef FRIENDLY_MODE
 
	  	  if(!is_friendly && HAL_GetTick() > 1000 * FRIENDLY_TIMEOUT)
 
	  	  {
 
	  		  transmission_rate = FRIENDLY_TX_RATE;
 
	  		  is_friendly = 1;
 
	  	  }
 
	  #endif
 
 
	  // Transmit RF packet
 
	  if(HAL_GetTick() - last_transmission > transmission_rate)
 
	  {
 
		  gps_update_data(); // Will always return at 1hz rate (default measurement rate)
 
 
		  #ifdef LPS25H
 
		  	  lps25h_read();
 
		  #else
 
		  	  bme280_update();
 
		  #endif
 
 
		  while(afsk_busy()); // ensure previous message finished
 
		  aprs_send();
 
 
		  last_transmission = HAL_GetTick();
 
	  }
 
 
	  // Blink LEDs
 
	  if(HAL_GetTick() - last_led > 100)
 
	  {
 
		  HAL_GPIO_TogglePin(LED_POWER);
 
		  last_led = HAL_GetTick();
 
	  }
 
 
	  if(afsk_request_cwoff())
 
		  si446x_cw_off();
 
 
	  // High-frequency function calls
 
	  watchdog_feed();
 
  }
0 comments (0 inline, 0 general)