kopia lustrzana https://github.com/DL7AD/pecanpico10
Changes...
- Implement ?aprsp so that it runs a one time beacon thread - Enable ?aprsp to respond from the profile of the rx call signpull/4/head
rodzic
b00cf100ca
commit
26b094c857
|
@ -121,6 +121,7 @@ typedef struct {
|
|||
char path[16];
|
||||
aprs_sym_t symbol;
|
||||
bool aprs_msg;
|
||||
bool run_once;
|
||||
} bcn_app_conf_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "radio.h"
|
||||
#include "flash.h"
|
||||
#include "image.h"
|
||||
#include "beacon.h"
|
||||
|
||||
#define METER_TO_FEET(m) (((m)*26876) / 8192)
|
||||
|
||||
|
@ -230,6 +231,8 @@ static char *aprs_parse_arguments(char *str, char **saveptr) {
|
|||
* @notes Known commands are in APRS command table.
|
||||
* @notes Commands themselves return only MSG_OK or MSG_ERROR.
|
||||
*
|
||||
* @param[in]
|
||||
*
|
||||
* @return result of command.
|
||||
* @retval MSG_OK if the command completed.
|
||||
* @retval MSG_ERROR if there was an error in command execution.
|
||||
|
@ -851,8 +854,21 @@ msg_t aprs_send_position_response(aprs_identity_t *id,
|
|||
if(argc != 0)
|
||||
return MSG_ERROR;
|
||||
/*
|
||||
* TODO: This should just send a request to the collector service.
|
||||
* Start a run once beacon thread.
|
||||
* The identity data has a ref to the bcn_app_conf_t object of the call sign.
|
||||
*/
|
||||
bcn_app_conf_t aprsd;
|
||||
if(id->beacon == NULL)
|
||||
aprsd = conf_sram.aprs.tx;
|
||||
else
|
||||
aprsd = *id->beacon;
|
||||
aprsd.run_once = true;
|
||||
thread_t * th = start_beacon_thread(&aprsd, "APRSD");
|
||||
if(th == NULL)
|
||||
return MSG_ERROR;
|
||||
return chThdWait(th);
|
||||
|
||||
/* //========================================================
|
||||
// Encode and transmit telemetry config first
|
||||
for(uint8_t type = 0; type < APRS_NUM_TELEM_GROUPS; type++) {
|
||||
packet_t packet = aprs_encode_telemetry_configuration(
|
||||
|
@ -897,7 +913,7 @@ msg_t aprs_send_position_response(aprs_identity_t *id,
|
|||
TRACE_ERROR("RX > Transmit of APRSP failed");
|
||||
return MSG_ERROR;
|
||||
}
|
||||
return MSG_OK;
|
||||
return MSG_OK;*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1121,6 +1137,7 @@ static bool aprs_decode_message(packet_t pp) {
|
|||
/*
|
||||
* Setup default responding app identity.
|
||||
* Default identity id set to tx.
|
||||
* TODO: Rework this identity stuff... messy
|
||||
*/
|
||||
|
||||
aprs_identity_t identity = {0};
|
||||
|
@ -1134,6 +1151,7 @@ static bool aprs_decode_message(packet_t pp) {
|
|||
identity.pwr = conf_sram.aprs.tx.radio_conf.pwr;
|
||||
identity.mod = conf_sram.aprs.tx.radio_conf.mod;
|
||||
identity.cca = conf_sram.aprs.tx.radio_conf.cca;
|
||||
identity.beacon = &conf_sram.aprs.tx;
|
||||
|
||||
/* Check which apps are enabled to accept APRS messages. */
|
||||
bool pos_pri = (strcmp(conf_sram.pos_pri.call, dest) == 0)
|
||||
|
@ -1144,6 +1162,7 @@ static bool aprs_decode_message(packet_t pp) {
|
|||
strcpy(identity.call, conf_sram.pos_pri.call);
|
||||
strcpy(identity.path, conf_sram.pos_pri.path);
|
||||
identity.symbol = conf_sram.pos_pri.symbol;
|
||||
identity.beacon = &conf_sram.pos_pri;
|
||||
}
|
||||
|
||||
bool pos_sec = (strcmp(conf_sram.pos_sec.call, dest) == 0)
|
||||
|
@ -1153,6 +1172,7 @@ static bool aprs_decode_message(packet_t pp) {
|
|||
strcpy(identity.call, conf_sram.pos_sec.call);
|
||||
strcpy(identity.path, conf_sram.pos_sec.path);
|
||||
identity.symbol = conf_sram.pos_sec.symbol;
|
||||
identity.beacon = &conf_sram.pos_sec;
|
||||
}
|
||||
|
||||
bool aprs_rx = (strcmp(conf_sram.aprs.rx.call, dest) == 0)
|
||||
|
@ -1161,6 +1181,7 @@ static bool aprs_decode_message(packet_t pp) {
|
|||
if(aprs_rx) {
|
||||
strcpy(identity.call, conf_sram.aprs.rx.call);
|
||||
identity.symbol = conf_sram.aprs.rx.symbol;
|
||||
identity.beacon = NULL;
|
||||
/* Other parameters come from tx identity. */
|
||||
}
|
||||
|
||||
|
|
|
@ -1,135 +1,136 @@
|
|||
/* trackuino copyright (C) 2010 EA5HAV Javi
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __APRS_H__
|
||||
#define __APRS_H__
|
||||
|
||||
#include "config.h"
|
||||
#include "si446x.h"
|
||||
#include "ax25_pad.h"
|
||||
#include "collector.h"
|
||||
|
||||
#define GSP_FIX_OLD 0x0
|
||||
#define GSP_FIX_CURRENT 0x1
|
||||
|
||||
#define NMEA_SRC_OTHER 0x0
|
||||
#define NMEA_SRC_GLL 0x1
|
||||
#define NMEA_SRC_GGA 0x2
|
||||
#define NMEA_SRC_RMC 0x3
|
||||
|
||||
#define ORIGIN_COMPRESSED 0x0
|
||||
#define ORIGIN_TNC_BTEXT 0x1
|
||||
#define ORIGIN_SOFTWARE 0x2
|
||||
#define ORIGIN_RESERVED 0x3
|
||||
#define ORIGIN_KPC3 0x4
|
||||
#define ORIGIN_PICO 0x5
|
||||
#define ORIGIN_OTHER_TRACKER 0x6
|
||||
#define ORIGIN_DIGIPEATER_CONVERSION 0x7
|
||||
|
||||
#define APRS_DEVICE_CALLSIGN "APECAN" // APExxx = Pecan device
|
||||
|
||||
#define SYM_BALLOON 0x2F4F
|
||||
#define SYM_SMALLAIRCRAFT 0x2F27
|
||||
#define SYM_SATELLITE 0x5C53
|
||||
#define SYM_CAR 0x2F3E
|
||||
#define SYM_SHIP 0x2F73
|
||||
#define SYM_DIGIPEATER 0x2F23
|
||||
#define SYM_ANTENNA 0x2F72
|
||||
|
||||
#define APRS_PATH_LENGTH 16
|
||||
|
||||
#define APRS_NUM_TELEM_GROUPS 4
|
||||
|
||||
#define APRS_HEARD_LIST_SIZE 20
|
||||
|
||||
#define APRS_MAX_MSG_ARGUMENTS 10
|
||||
|
||||
typedef struct APRSIdentity {
|
||||
/* APRS parameters. */
|
||||
char num[8]; /**< @brief Message number. */
|
||||
char src[AX25_MAX_ADDR_LEN]; /**< @brief Source call. */
|
||||
char call[AX25_MAX_ADDR_LEN]; /**< @brief Destination call. */
|
||||
char path[APRS_PATH_LENGTH]; /**< @brief Path. */
|
||||
aprs_sym_t symbol; /**< @brief symbol. */
|
||||
/* Radio parameters. */
|
||||
radio_freq_t freq;
|
||||
radio_pwr_t pwr;
|
||||
mod_t mod;
|
||||
radio_squelch_t cca;
|
||||
} aprs_identity_t;
|
||||
|
||||
/**
|
||||
* @brief Command handler function type.
|
||||
*/
|
||||
typedef msg_t (*aprscmd_t)(aprs_identity_t *id, int argc, char *argv[]);
|
||||
|
||||
/**
|
||||
* @brief APRS command entry type.
|
||||
*/
|
||||
typedef struct {
|
||||
const char *ac_name; /**< @brief Command name. */
|
||||
aprscmd_t ac_function; /**< @brief Command function. */
|
||||
} APRSCommand;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void aprs_debug_getPacket(packet_t pp, char* buf, uint32_t len);
|
||||
packet_t aprs_encode_stamped_position_and_telemetry(const char *callsign,
|
||||
const char *path, aprs_sym_t symbol,
|
||||
dataPoint_t *dataPoint);
|
||||
packet_t aprs_encode_position_and_telemetry(const char *callsign,
|
||||
const char *path,
|
||||
aprs_sym_t symbol,
|
||||
dataPoint_t *dataPoint, bool extended);
|
||||
packet_t aprs_encode_telemetry_configuration(const char *originator,
|
||||
const char *path,
|
||||
const char *destination,
|
||||
uint8_t type);
|
||||
packet_t aprs_encode_message(const char *callsign, const char *path,
|
||||
const char *receiver, const char *text,
|
||||
const bool ack);
|
||||
packet_t aprs_encode_data_packet(const char *callsign, const char *path,
|
||||
char packetType, uint8_t *data);
|
||||
packet_t aprs_compose_aprsd_message(const char *callsign, const char *path,
|
||||
const char *receiver);
|
||||
void aprs_decode_packet(packet_t pp);
|
||||
msg_t aprs_send_position_response(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_send_aprsd_message(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_send_aprsh_message(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_execute_gpio_command(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_handle_gps_command(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_execute_config_command(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_execute_config_save(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_execute_img_command(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_execute_system_reset(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __APRS_H__ */
|
||||
|
||||
/* trackuino copyright (C) 2010 EA5HAV Javi
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __APRS_H__
|
||||
#define __APRS_H__
|
||||
|
||||
#include "config.h"
|
||||
#include "si446x.h"
|
||||
#include "ax25_pad.h"
|
||||
#include "collector.h"
|
||||
|
||||
#define GSP_FIX_OLD 0x0
|
||||
#define GSP_FIX_CURRENT 0x1
|
||||
|
||||
#define NMEA_SRC_OTHER 0x0
|
||||
#define NMEA_SRC_GLL 0x1
|
||||
#define NMEA_SRC_GGA 0x2
|
||||
#define NMEA_SRC_RMC 0x3
|
||||
|
||||
#define ORIGIN_COMPRESSED 0x0
|
||||
#define ORIGIN_TNC_BTEXT 0x1
|
||||
#define ORIGIN_SOFTWARE 0x2
|
||||
#define ORIGIN_RESERVED 0x3
|
||||
#define ORIGIN_KPC3 0x4
|
||||
#define ORIGIN_PICO 0x5
|
||||
#define ORIGIN_OTHER_TRACKER 0x6
|
||||
#define ORIGIN_DIGIPEATER_CONVERSION 0x7
|
||||
|
||||
#define APRS_DEVICE_CALLSIGN "APECAN" // APExxx = Pecan device
|
||||
|
||||
#define SYM_BALLOON 0x2F4F
|
||||
#define SYM_SMALLAIRCRAFT 0x2F27
|
||||
#define SYM_SATELLITE 0x5C53
|
||||
#define SYM_CAR 0x2F3E
|
||||
#define SYM_SHIP 0x2F73
|
||||
#define SYM_DIGIPEATER 0x2F23
|
||||
#define SYM_ANTENNA 0x2F72
|
||||
|
||||
#define APRS_PATH_LENGTH 16
|
||||
|
||||
#define APRS_NUM_TELEM_GROUPS 4
|
||||
|
||||
#define APRS_HEARD_LIST_SIZE 20
|
||||
|
||||
#define APRS_MAX_MSG_ARGUMENTS 10
|
||||
|
||||
typedef struct APRSIdentity {
|
||||
/* APRS parameters. */
|
||||
char num[8]; /**< @brief Message number. */
|
||||
char src[AX25_MAX_ADDR_LEN]; /**< @brief Source call. */
|
||||
char call[AX25_MAX_ADDR_LEN]; /**< @brief Destination call. */
|
||||
char path[APRS_PATH_LENGTH]; /**< @brief Path. */
|
||||
aprs_sym_t symbol; /**< @brief symbol. */
|
||||
bcn_app_conf_t *beacon;
|
||||
/* Radio parameters. */
|
||||
radio_freq_t freq;
|
||||
radio_pwr_t pwr;
|
||||
mod_t mod;
|
||||
radio_squelch_t cca;
|
||||
} aprs_identity_t;
|
||||
|
||||
/**
|
||||
* @brief Command handler function type.
|
||||
*/
|
||||
typedef msg_t (*aprscmd_t)(aprs_identity_t *id, int argc, char *argv[]);
|
||||
|
||||
/**
|
||||
* @brief APRS command entry type.
|
||||
*/
|
||||
typedef struct {
|
||||
const char *ac_name; /**< @brief Command name. */
|
||||
aprscmd_t ac_function; /**< @brief Command function. */
|
||||
} APRSCommand;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void aprs_debug_getPacket(packet_t pp, char* buf, uint32_t len);
|
||||
packet_t aprs_encode_stamped_position_and_telemetry(const char *callsign,
|
||||
const char *path, aprs_sym_t symbol,
|
||||
dataPoint_t *dataPoint);
|
||||
packet_t aprs_encode_position_and_telemetry(const char *callsign,
|
||||
const char *path,
|
||||
aprs_sym_t symbol,
|
||||
dataPoint_t *dataPoint, bool extended);
|
||||
packet_t aprs_encode_telemetry_configuration(const char *originator,
|
||||
const char *path,
|
||||
const char *destination,
|
||||
uint8_t type);
|
||||
packet_t aprs_encode_message(const char *callsign, const char *path,
|
||||
const char *receiver, const char *text,
|
||||
const bool ack);
|
||||
packet_t aprs_encode_data_packet(const char *callsign, const char *path,
|
||||
char packetType, uint8_t *data);
|
||||
packet_t aprs_compose_aprsd_message(const char *callsign, const char *path,
|
||||
const char *receiver);
|
||||
void aprs_decode_packet(packet_t pp);
|
||||
msg_t aprs_send_position_response(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_send_aprsd_message(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_send_aprsh_message(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_execute_gpio_command(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_handle_gps_command(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_execute_config_command(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_execute_config_save(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_execute_img_command(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
msg_t aprs_execute_system_reset(aprs_identity_t *id,
|
||||
int argc, char *argv[]);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __APRS_H__ */
|
||||
|
||||
|
|
|
@ -460,13 +460,13 @@ THD_FUNCTION(collectorThread, arg) {
|
|||
TRACE_INFO("COLL > Acquire time using GPS");
|
||||
if(aquirePosition(newDataPoint, lastDataPoint, gps_wait_time - TIME_S2I(3))) {
|
||||
/* Acquisition succeeded. */
|
||||
TRACE_INFO("COLL > Time acquisition from GPS succeeded");
|
||||
TRACE_INFO("COLL > Time update acquired from GPS");
|
||||
/* Update with freshly acquired data. */
|
||||
lastDataPoint = newDataPoint;
|
||||
GPS_Deinit();
|
||||
} else {
|
||||
/* Time is stale record. */
|
||||
TRACE_INFO("COLL > Fresh time not acquired from GPS");
|
||||
TRACE_INFO("COLL > Time update not acquired from GPS");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,6 +145,8 @@ THD_FUNCTION(bcnThread, arg) {
|
|||
chThdSleep(TIME_S2I(5));
|
||||
}
|
||||
} /* psleep */
|
||||
if(conf->run_once)
|
||||
chThdExit(MSG_OK);
|
||||
time = waitForTrigger(time, conf->beacon.cycle);
|
||||
}
|
||||
}
|
||||
|
@ -152,12 +154,13 @@ THD_FUNCTION(bcnThread, arg) {
|
|||
/*
|
||||
*
|
||||
*/
|
||||
void start_beacon_thread(bcn_app_conf_t *conf) {
|
||||
thread_t * start_beacon_thread(bcn_app_conf_t *conf, const char *name) {
|
||||
thread_t *th = chThdCreateFromHeap(NULL, THD_WORKING_AREA_SIZE(10*1024),
|
||||
"BCN", LOWPRIO, bcnThread, conf);
|
||||
name, LOWPRIO, bcnThread, conf);
|
||||
if(!th) {
|
||||
// Print startup error, do not start watchdog for this thread
|
||||
TRACE_ERROR("BCN > Could not start thread (not enough memory available)");
|
||||
}
|
||||
return th;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void start_beacon_thread(bcn_app_conf_t *conf);
|
||||
thread_t * start_beacon_thread(bcn_app_conf_t *conf, const char *name);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -43,9 +43,9 @@ void start_user_threads(void)
|
|||
|
||||
/* TODO: Implement scheduler that will run threads based on schedule. */
|
||||
if(conf_sram.pos_pri.beacon.active)
|
||||
start_beacon_thread(&conf_sram.pos_pri);
|
||||
start_beacon_thread(&conf_sram.pos_pri, "POS1");
|
||||
if(conf_sram.pos_sec.beacon.active)
|
||||
start_beacon_thread(&conf_sram.pos_sec);
|
||||
start_beacon_thread(&conf_sram.pos_sec, "POS2");
|
||||
|
||||
if(conf_sram.img_pri.svc_conf.active)
|
||||
start_image_thread(&conf_sram.img_pri);
|
||||
|
@ -58,7 +58,7 @@ void start_user_threads(void)
|
|||
if(conf_sram.aprs.rx.svc_conf.active
|
||||
&& conf_sram.aprs.digi
|
||||
&& conf_sram.aprs.tx.beacon.active) {
|
||||
start_beacon_thread(&conf_sram.aprs.tx);
|
||||
start_beacon_thread(&conf_sram.aprs.tx, "BCN");
|
||||
}
|
||||
|
||||
if(conf_sram.aprs.rx.svc_conf.active) {
|
||||
|
|
Ładowanie…
Reference in New Issue