kopia lustrzana https://github.com/DL7AD/pecanpico10
Refactor radio frequency calculations. Revise config.c use of .rssi
- Check of special frequencies (GEOFENCE, etc.) now in common func. - Change config.c entries of .rssi .cca entries for TX identities.pull/4/head
rodzic
08bf7939e2
commit
18cee6a431
|
|
@ -19,7 +19,7 @@ const conf_t conf_flash_default = {
|
|||
.pwr = 0x7F,
|
||||
.freq = FREQ_APRS_RECEIVE,
|
||||
.mod = MOD_AFSK,
|
||||
.rssi = 0x4F,
|
||||
.cca = 0x4F,
|
||||
},
|
||||
// Node identity
|
||||
.call = "VK2GJ-12",
|
||||
|
|
@ -41,7 +41,7 @@ const conf_t conf_flash_default = {
|
|||
.pwr = 0x7F,
|
||||
.freq = FREQ_APRS_DYNAMIC,
|
||||
.mod = MOD_AFSK,
|
||||
.rssi = 0x4F
|
||||
.cca = 0x4F
|
||||
},
|
||||
// Node identity
|
||||
.call = "DL7AD-14",
|
||||
|
|
@ -64,7 +64,7 @@ const conf_t conf_flash_default = {
|
|||
.pwr = 0x7F,
|
||||
.freq = 144800000,
|
||||
.mod = MOD_2FSK,
|
||||
.rssi = 0x4F,
|
||||
.cca = 0x4F,
|
||||
.redundantTx = false
|
||||
},
|
||||
// Node identity
|
||||
|
|
@ -88,7 +88,7 @@ const conf_t conf_flash_default = {
|
|||
.pwr = 0x7F,
|
||||
.freq = 145175000,
|
||||
.mod = MOD_AFSK,
|
||||
.rssi = 0x4F
|
||||
.cca = 0x4F
|
||||
},
|
||||
// Node identity
|
||||
.call = "VK2GJ-14",
|
||||
|
|
@ -110,7 +110,7 @@ const conf_t conf_flash_default = {
|
|||
.pwr = 0x7F,
|
||||
.freq = FREQ_APRS_DYNAMIC,
|
||||
.mod = MOD_AFSK,
|
||||
.rssi = 0x4F
|
||||
.cca = 0x4F
|
||||
},
|
||||
// Node identity
|
||||
.call = "VK2GJ-13",
|
||||
|
|
@ -138,7 +138,7 @@ const conf_t conf_flash_default = {
|
|||
.freq = FREQ_APRS_RECEIVE,
|
||||
.pwr = 0x7F,
|
||||
.mod = MOD_AFSK,
|
||||
.rssi = 0x4F
|
||||
.cca = 0x4F
|
||||
},
|
||||
// Node tx identity
|
||||
.call = "VK2GJ-5",
|
||||
|
|
@ -155,7 +155,7 @@ const conf_t conf_flash_default = {
|
|||
.base = {
|
||||
// The base station identity
|
||||
// Tracker originated messages can be sent to this call sign sent
|
||||
.enabled = false,
|
||||
.enabled = true,
|
||||
.call = "VK2GJ-7",
|
||||
.path = "WIDE2-1",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ void usb_cmd_send_aprs_message(BaseSequentialStream *chp, int argc, char *argv[]
|
|||
0,
|
||||
conf_sram.aprs.tx.radio_conf.pwr,
|
||||
conf_sram.aprs.tx.radio_conf.mod,
|
||||
conf_sram.aprs.tx.radio_conf.rssi);
|
||||
conf_sram.aprs.tx.radio_conf.cca);
|
||||
|
||||
chprintf(chp, "Message sent!\r\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -561,7 +561,7 @@ static bool Si446x_transmit(radio_unit_t radio,
|
|||
radio_squelch_t rssi,
|
||||
sysinterval_t cca_timeout) {
|
||||
|
||||
radio_freq_t op_freq = pktComputeOperatingFrequency(freq, step, chan);
|
||||
radio_freq_t op_freq = pktComputeOperatingFrequency(radio, freq, step, chan);
|
||||
|
||||
if(!pktIsRadioInBand(radio, op_freq)) {
|
||||
TRACE_ERROR("SI > Frequency out of range");
|
||||
|
|
@ -640,7 +640,7 @@ bool Si446x_receiveNoLock(radio_unit_t radio,
|
|||
radio_ch_t channel,
|
||||
radio_squelch_t rssi,
|
||||
mod_t mod) {
|
||||
radio_freq_t op_freq = pktComputeOperatingFrequency(freq, step, channel);
|
||||
radio_freq_t op_freq = pktComputeOperatingFrequency(radio, freq, step, channel);
|
||||
/* TODO: compute f + s*c. */
|
||||
if(!pktIsRadioInBand(radio, op_freq)) {
|
||||
TRACE_ERROR("SI > Frequency out of range");
|
||||
|
|
@ -699,7 +699,8 @@ bool Si4464_resumeReceive(radio_unit_t radio,
|
|||
(void)radio;
|
||||
bool ret = true;
|
||||
|
||||
radio_freq_t op_freq = pktComputeOperatingFrequency(rx_frequency,
|
||||
radio_freq_t op_freq = pktComputeOperatingFrequency(radio,
|
||||
rx_frequency,
|
||||
rx_step,
|
||||
rx_chan);
|
||||
|
||||
|
|
@ -825,7 +826,7 @@ THD_FUNCTION(bloc_si_fifo_feeder_afsk, arg) {
|
|||
|
||||
/*
|
||||
* Use the specified CCA RSSI level.
|
||||
* RSSI will be set to blind send after first packet.
|
||||
* CCA level will be set to blind send after first packet.
|
||||
*/
|
||||
radio_squelch_t rssi = rto->squelch;
|
||||
|
||||
|
|
@ -1081,7 +1082,7 @@ THD_FUNCTION(bloc_si_fifo_feeder_fsk, arg) {
|
|||
|
||||
/*
|
||||
* Use the specified CCA RSSI level.
|
||||
* RSSI will be set to blind send after first packet.
|
||||
* CCA will be set to blind send after first packet.
|
||||
*/
|
||||
radio_squelch_t rssi = rto->squelch;
|
||||
|
||||
|
|
|
|||
|
|
@ -249,24 +249,7 @@ bool Si446x_setBandParameters(radio_unit_t radio,
|
|||
radio_freq_t freq,
|
||||
channel_hz_t step);
|
||||
|
||||
/* TODO: Forward need for declaration. */
|
||||
radio_freq_t pktComputeOperatingFrequency(radio_freq_t base_freq,
|
||||
channel_hz_t step,
|
||||
radio_ch_t chan);
|
||||
|
||||
static inline bool Si446x_isFrequencyInBand(radio_unit_t radio,
|
||||
radio_freq_t base_freq,
|
||||
channel_hz_t step,
|
||||
radio_ch_t chan) {
|
||||
(void)radio;
|
||||
|
||||
radio_freq_t freq = pktComputeOperatingFrequency(base_freq,
|
||||
step,
|
||||
chan);
|
||||
|
||||
/* TODO: Lookup frequency band table for radio. */
|
||||
return (Si446x_MIN_FREQ <= freq && freq < Si446x_MAX_FREQ);
|
||||
}
|
||||
|
||||
extern void pktReleasePacketBuffer(packet_t pp);
|
||||
|
||||
|
|
|
|||
|
|
@ -497,6 +497,7 @@ void pktReleaseRadio(radio_unit_t radio) {
|
|||
|
||||
/**
|
||||
* @brief Compute an operating frequency.
|
||||
* @notes All special frequency parameters are handled.
|
||||
*
|
||||
* @param[in] base_freq Radio base frequency.
|
||||
* @param[in] step Radio channel step frequency.
|
||||
|
|
@ -504,22 +505,40 @@ void pktReleaseRadio(radio_unit_t radio) {
|
|||
*
|
||||
* @api
|
||||
*/
|
||||
radio_freq_t pktComputeOperatingFrequency(radio_freq_t base_freq,
|
||||
radio_freq_t pktComputeOperatingFrequency(radio_unit_t radio,
|
||||
radio_freq_t base_freq,
|
||||
channel_hz_t step,
|
||||
radio_ch_t chan) {
|
||||
|
||||
if(base_freq == FREQ_APRS_DYNAMIC) {
|
||||
base_freq = getAPRSRegionFrequency(); // Get transmission frequency by geofencing
|
||||
// If using geofence ignore channel and step.
|
||||
chan = 0;
|
||||
step = 0;
|
||||
if(base_freq == FREQ_APRS_RECEIVE) {
|
||||
/* Get current RX frequency (if valid) and use that. */
|
||||
packet_svc_t *handler = pktGetServiceObject(radio);
|
||||
if(pktIsReceiveActive(radio)) {
|
||||
base_freq = handler->radio_rx_config.base_frequency;
|
||||
step = handler->radio_rx_config.step_hz;
|
||||
chan = handler->radio_rx_config.channel;
|
||||
} else
|
||||
base_freq = FREQ_APRS_DYNAMIC;
|
||||
}
|
||||
|
||||
return base_freq + (step * chan);
|
||||
if(base_freq == FREQ_APRS_DYNAMIC) {
|
||||
/* Get frequency by geofencing. */
|
||||
base_freq = getAPRSRegionFrequency();
|
||||
/*
|
||||
* If using geofence ignore channel and step for now.
|
||||
* TODO: Could compute base + step + channel and update PKT object?
|
||||
*/
|
||||
chan = 0;
|
||||
step = 0;
|
||||
}
|
||||
|
||||
/* Calculate operating frequency. */
|
||||
uint32_t op_freq = base_freq + (step * chan);
|
||||
return pktIsRadioInBand(radio, op_freq) ? op_freq : FREQ_RADIO_INVALID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if requested frequency is in bad for the radio.
|
||||
* @brief Check if requested frequency is in band for the radio.
|
||||
*
|
||||
* @param[in] radio radio unit ID.
|
||||
* @param[in] freq Radio frequency.
|
||||
|
|
|
|||
|
|
@ -106,7 +106,8 @@ extern "C" {
|
|||
thread_t *thread);
|
||||
msg_t pktAcquireRadio(radio_unit_t radio, sysinterval_t timeout);
|
||||
void pktReleaseRadio(radio_unit_t radio);
|
||||
radio_freq_t pktComputeOperatingFrequency(radio_freq_t base_freq,
|
||||
radio_freq_t pktComputeOperatingFrequency(radio_unit_t radio,
|
||||
radio_freq_t base_freq,
|
||||
channel_hz_t step,
|
||||
radio_ch_t chan);
|
||||
bool pktIsRadioInBand(radio_unit_t radio, radio_freq_t freq);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ const conf_command_t command_list[] = {
|
|||
{TYPE_INT, "pos_pri.pwr", sizeof(conf_sram.pos_pri.radio_conf.pwr), &conf_sram.pos_pri.radio_conf.pwr },
|
||||
{TYPE_INT, "pos_pri.freq", sizeof(conf_sram.pos_pri.radio_conf.freq), &conf_sram.pos_pri.radio_conf.freq },
|
||||
{TYPE_INT, "pos_pri.mod", sizeof(conf_sram.pos_pri.radio_conf.mod), &conf_sram.pos_pri.radio_conf.mod },
|
||||
{TYPE_INT, "pos_pri.rssi", sizeof(conf_sram.pos_pri.radio_conf.rssi), &conf_sram.pos_pri.radio_conf.rssi },
|
||||
{TYPE_INT, "pos_pri.cca", sizeof(conf_sram.pos_pri.radio_conf.cca), &conf_sram.pos_pri.radio_conf.cca },
|
||||
{TYPE_STR, "pos_pri.call", sizeof(conf_sram.pos_pri.call), &conf_sram.pos_pri.call },
|
||||
{TYPE_STR, "pos_pri.path", sizeof(conf_sram.pos_pri.path), &conf_sram.pos_pri.path },
|
||||
{TYPE_INT, "pos_pri.symbol", sizeof(conf_sram.pos_pri.symbol), &conf_sram.pos_pri.symbol },
|
||||
|
|
@ -68,7 +68,7 @@ const conf_command_t command_list[] = {
|
|||
{TYPE_INT, "pos_sec.pwr", sizeof(conf_sram.pos_sec.radio_conf.pwr), &conf_sram.pos_sec.radio_conf.pwr },
|
||||
{TYPE_INT, "pos_sec.freq", sizeof(conf_sram.pos_sec.radio_conf.freq), &conf_sram.pos_sec.radio_conf.freq },
|
||||
{TYPE_INT, "pos_sec.mod", sizeof(conf_sram.pos_sec.radio_conf.mod), &conf_sram.pos_sec.radio_conf.mod },
|
||||
{TYPE_INT, "pos_sec.rssi", sizeof(conf_sram.pos_sec.radio_conf.rssi), &conf_sram.pos_sec.radio_conf.rssi },
|
||||
{TYPE_INT, "pos_sec.cca", sizeof(conf_sram.pos_sec.radio_conf.cca), &conf_sram.pos_sec.radio_conf.cca },
|
||||
{TYPE_STR, "pos_sec.call", sizeof(conf_sram.pos_sec.call), &conf_sram.pos_sec.call },
|
||||
{TYPE_STR, "pos_sec.path", sizeof(conf_sram.pos_sec.path), &conf_sram.pos_sec.path },
|
||||
{TYPE_INT, "pos_sec.symbol", sizeof(conf_sram.pos_sec.symbol), &conf_sram.pos_sec.symbol },
|
||||
|
|
@ -85,7 +85,7 @@ const conf_command_t command_list[] = {
|
|||
{TYPE_INT, "img_pri.pwr", sizeof(conf_sram.img_pri.radio_conf.pwr), &conf_sram.img_pri.radio_conf.pwr },
|
||||
{TYPE_INT, "img_pri.freq", sizeof(conf_sram.img_pri.radio_conf.freq), &conf_sram.img_pri.radio_conf.freq },
|
||||
{TYPE_INT, "img_pri.mod", sizeof(conf_sram.img_pri.radio_conf.mod), &conf_sram.img_pri.radio_conf.mod },
|
||||
{TYPE_INT, "img_pri.rssi", sizeof(conf_sram.img_pri.radio_conf.rssi), &conf_sram.img_pri.radio_conf.rssi },
|
||||
{TYPE_INT, "img_pri.cca", sizeof(conf_sram.img_pri.radio_conf.cca), &conf_sram.img_pri.radio_conf.cca },
|
||||
{TYPE_INT, "img_pri.speed", sizeof(conf_sram.img_pri.radio_conf.speed), &conf_sram.img_pri.radio_conf.speed },
|
||||
{TYPE_INT, "img_pri.redundantTx", sizeof(conf_sram.img_pri.radio_conf.redundantTx), &conf_sram.img_pri.radio_conf.redundantTx },
|
||||
{TYPE_STR, "img_pri.call", sizeof(conf_sram.img_pri.call), &conf_sram.img_pri.call },
|
||||
|
|
@ -104,7 +104,7 @@ const conf_command_t command_list[] = {
|
|||
{TYPE_INT, "img_sec.pwr", sizeof(conf_sram.img_sec.radio_conf.pwr), &conf_sram.img_sec.radio_conf.pwr },
|
||||
{TYPE_INT, "img_sec.freq", sizeof(conf_sram.img_sec.radio_conf.freq), &conf_sram.img_sec.radio_conf.freq },
|
||||
{TYPE_INT, "img_sec.mod", sizeof(conf_sram.img_sec.radio_conf.mod), &conf_sram.img_sec.radio_conf.mod },
|
||||
{TYPE_INT, "img_sec.rssi", sizeof(conf_sram.img_sec.radio_conf.rssi), &conf_sram.img_sec.radio_conf.rssi },
|
||||
{TYPE_INT, "img_sec.cca", sizeof(conf_sram.img_sec.radio_conf.cca), &conf_sram.img_sec.radio_conf.cca },
|
||||
{TYPE_INT, "img_sec.speed", sizeof(conf_sram.img_sec.radio_conf.speed), &conf_sram.img_sec.radio_conf.speed },
|
||||
{TYPE_INT, "img_sec.redundantTx", sizeof(conf_sram.img_sec.radio_conf.redundantTx), &conf_sram.img_sec.radio_conf.redundantTx },
|
||||
{TYPE_STR, "img_sec.call", sizeof(conf_sram.img_sec.call), &conf_sram.img_sec.call },
|
||||
|
|
@ -123,7 +123,7 @@ const conf_command_t command_list[] = {
|
|||
{TYPE_INT, "log.pwr", sizeof(conf_sram.log.radio_conf.pwr), &conf_sram.log.radio_conf.pwr },
|
||||
{TYPE_INT, "log.freq", sizeof(conf_sram.log.radio_conf.freq), &conf_sram.log.radio_conf.freq },
|
||||
{TYPE_INT, "log.mod", sizeof(conf_sram.log.radio_conf.mod), &conf_sram.log.radio_conf.mod },
|
||||
{TYPE_INT, "log.rssi", sizeof(conf_sram.log.radio_conf.rssi), &conf_sram.log.radio_conf.rssi },
|
||||
{TYPE_INT, "log.cca", sizeof(conf_sram.log.radio_conf.cca), &conf_sram.log.radio_conf.cca },
|
||||
{TYPE_INT, "log.speed", sizeof(conf_sram.log.radio_conf.speed), &conf_sram.log.radio_conf.speed },
|
||||
{TYPE_INT, "log.redundantTx", sizeof(conf_sram.log.radio_conf.redundantTx), &conf_sram.log.radio_conf.redundantTx },
|
||||
{TYPE_STR, "log.call", sizeof(conf_sram.log.call), &conf_sram.log.call },
|
||||
|
|
@ -141,13 +141,13 @@ const conf_command_t command_list[] = {
|
|||
{TYPE_INT, "aprs.base.freq", sizeof(conf_sram.aprs.base.radio_conf.freq), &conf_sram.aprs.base.radio_conf.freq },
|
||||
{TYPE_INT, "aprs.base.pwr", sizeof(conf_sram.aprs.base.radio_conf.pwr), &conf_sram.aprs.base.radio_conf.pwr },
|
||||
{TYPE_INT, "aprs.base.mod", sizeof(conf_sram.aprs.base.radio_conf.mod), &conf_sram.aprs.base.radio_conf.mod },
|
||||
{TYPE_INT, "aprs.base.rssi", sizeof(conf_sram.aprs.base.radio_conf.rssi), &conf_sram.aprs.base.radio_conf.rssi },
|
||||
{TYPE_INT, "aprs.base.cca", sizeof(conf_sram.aprs.base.radio_conf.cca), &conf_sram.aprs.base.radio_conf.cca },
|
||||
{TYPE_STR, "aprs.base.call", sizeof(conf_sram.aprs.base.call), &conf_sram.aprs.base.call },
|
||||
|
||||
{TYPE_INT, "aprs.tx.freq", sizeof(conf_sram.aprs.tx.radio_conf.freq), &conf_sram.aprs.tx.radio_conf.freq },
|
||||
{TYPE_INT, "aprs.tx.pwr", sizeof(conf_sram.aprs.tx.radio_conf.pwr), &conf_sram.aprs.tx.radio_conf.pwr },
|
||||
{TYPE_INT, "aprs.tx.mod", sizeof(conf_sram.aprs.tx.radio_conf.mod), &conf_sram.aprs.tx.radio_conf.mod },
|
||||
{TYPE_INT, "aprs.tx.rssi", sizeof(conf_sram.aprs.tx.radio_conf.rssi), &conf_sram.aprs.tx.radio_conf.rssi },
|
||||
{TYPE_INT, "aprs.tx.cca", sizeof(conf_sram.aprs.tx.radio_conf.cca), &conf_sram.aprs.tx.radio_conf.cca },
|
||||
{TYPE_STR, "aprs.tx.call", sizeof(conf_sram.aprs.tx.call), &conf_sram.aprs.tx.call },
|
||||
{TYPE_STR, "aprs.tx.path", sizeof(conf_sram.aprs.tx.path), &conf_sram.aprs.tx.path },
|
||||
{TYPE_INT, "aprs.tx.symbol", sizeof(conf_sram.aprs.tx.symbol), &conf_sram.aprs.tx.symbol },
|
||||
|
|
@ -467,7 +467,7 @@ msg_t aprs_send_aprsd_message(aprs_identity_t *id,
|
|||
0,
|
||||
id->pwr,
|
||||
id->mod,
|
||||
id->rssi)) {
|
||||
id->cca)) {
|
||||
TRACE_ERROR("RX > Transmit of APRSD failed");
|
||||
return MSG_ERROR;
|
||||
}
|
||||
|
|
@ -518,7 +518,7 @@ msg_t aprs_send_aprsh_message(aprs_identity_t *id,
|
|||
0,
|
||||
id->pwr,
|
||||
id->mod,
|
||||
id->rssi)) {
|
||||
id->cca)) {
|
||||
TRACE_ERROR("RX > Transmit of APRSH failed");
|
||||
return MSG_ERROR;
|
||||
}
|
||||
|
|
@ -573,7 +573,7 @@ msg_t aprs_execute_gpio_command(aprs_identity_t *id,
|
|||
0,
|
||||
id->pwr,
|
||||
id->mod,
|
||||
id->rssi)) {
|
||||
id->cca)) {
|
||||
TRACE_ERROR("RX > Transmit of GPIO status failed");
|
||||
return MSG_ERROR;
|
||||
}
|
||||
|
|
@ -671,7 +671,7 @@ msg_t aprs_send_position_beacon(aprs_identity_t *id,
|
|||
0,
|
||||
id->pwr,
|
||||
id->mod,
|
||||
id->rssi)) {
|
||||
id->cca)) {
|
||||
TRACE_ERROR("RX > Transmit of APRSD failed");
|
||||
return MSG_ERROR;
|
||||
}
|
||||
|
|
@ -711,7 +711,7 @@ msg_t aprs_execute_system_reset(aprs_identity_t *id,
|
|||
0,
|
||||
id->pwr,
|
||||
id->mod,
|
||||
id->rssi);
|
||||
id->cca);
|
||||
|
||||
chThdSleep(TIME_S2I(10));
|
||||
|
||||
|
|
@ -911,7 +911,7 @@ static bool aprs_decode_message(packet_t pp) {
|
|||
identity.freq = conf_sram.aprs.tx.radio_conf.freq;
|
||||
identity.pwr = conf_sram.aprs.tx.radio_conf.pwr;
|
||||
identity.mod = conf_sram.aprs.tx.radio_conf.mod;
|
||||
identity.rssi = conf_sram.aprs.tx.radio_conf.rssi;
|
||||
identity.cca = conf_sram.aprs.tx.radio_conf.cca;
|
||||
|
||||
/* Check which nodes are enabled to accept aprs messages. */
|
||||
bool pos_pri = !strcmp(conf_sram.pos_pri.call, dest)
|
||||
|
|
@ -1034,7 +1034,7 @@ static bool aprs_decode_message(packet_t pp) {
|
|||
0,
|
||||
identity.pwr,
|
||||
identity.mod,
|
||||
identity.rssi);
|
||||
identity.cca);
|
||||
}
|
||||
/* Flag that the APRS content should not be digipeated. */
|
||||
return false;
|
||||
|
|
@ -1062,10 +1062,10 @@ static void aprs_digipeat(packet_t pp) {
|
|||
0,
|
||||
conf_sram.aprs.tx.radio_conf.pwr,
|
||||
conf_sram.aprs.tx.radio_conf.mod,
|
||||
conf_sram.aprs.tx.radio_conf.rssi)) {
|
||||
conf_sram.aprs.tx.radio_conf.cca)) {
|
||||
TRACE_INFO("RX > Failed to digipeat packet");
|
||||
} /* TX failed. */
|
||||
} /* Should be digipteated. */
|
||||
} /* Should be digipeated. */
|
||||
} /* Duplicate check. */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ typedef struct APRSIdentity {
|
|||
uint32_t freq;
|
||||
uint8_t pwr;
|
||||
mod_t mod;
|
||||
uint8_t rssi;
|
||||
uint8_t cca;
|
||||
} aprs_identity_t;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ THD_FUNCTION(bcnThread, arg) {
|
|||
0,
|
||||
conf->tx.radio_conf.pwr,
|
||||
conf->tx.radio_conf.mod,
|
||||
conf->tx.radio_conf.rssi)) {
|
||||
conf->tx.radio_conf.cca)) {
|
||||
TRACE_ERROR("BCN > failed to transmit beacon data");
|
||||
}
|
||||
chThdSleep(TIME_S2I(5));
|
||||
|
|
@ -72,37 +72,36 @@ THD_FUNCTION(bcnThread, arg) {
|
|||
/*
|
||||
* Encode/Transmit APRSD packet.
|
||||
* This is a tracker originated message (not a reply to a request).
|
||||
* The message will be sent to the base station set in path.
|
||||
* The message will be sent to the base station set in path if set.
|
||||
* Else send it to device identity.
|
||||
*/
|
||||
if(conf_sram.aprs.base.enabled) {
|
||||
/*
|
||||
* Send message from this device.
|
||||
* Use call sign and path as specified in base config.
|
||||
* There is no acknowledgment requested.
|
||||
*/
|
||||
packet = aprs_compose_aprsd_message(
|
||||
conf->tx.call,
|
||||
conf->base.path,
|
||||
conf->base.call);
|
||||
if(packet == NULL) {
|
||||
TRACE_WARN("BCN > No free packet objects "
|
||||
"or badly formed APRSD message");
|
||||
} else {
|
||||
if(!transmitOnRadio(packet,
|
||||
conf->tx.radio_conf.freq,
|
||||
0,
|
||||
0,
|
||||
conf->tx.radio_conf.pwr,
|
||||
conf->tx.radio_conf.mod,
|
||||
conf->tx.radio_conf.rssi
|
||||
)) {
|
||||
TRACE_ERROR("BCN > Failed to transmit APRSD data");
|
||||
}
|
||||
chThdSleep(TIME_S2I(5));
|
||||
}
|
||||
char *call = conf_sram.aprs.base.enabled
|
||||
? conf_sram.aprs.base.call : APRS_DEVICE_CALLSIGN;
|
||||
|
||||
/*
|
||||
* Send message from this device.
|
||||
* Use call sign and path as specified in base config.
|
||||
* There is no acknowledgment requested.
|
||||
*/
|
||||
packet = aprs_compose_aprsd_message(
|
||||
conf->tx.call,
|
||||
conf->base.path,
|
||||
call);
|
||||
if(packet == NULL) {
|
||||
TRACE_WARN("BCN > No free packet objects "
|
||||
"or badly formed APRSD message");
|
||||
} else {
|
||||
/* TODO: Implement a fallback destination if no base station set? */
|
||||
TRACE_INFO("BCN > APRSD data not sent - no base station specified");
|
||||
if(!transmitOnRadio(packet,
|
||||
conf->tx.radio_conf.freq,
|
||||
0,
|
||||
0,
|
||||
conf->tx.radio_conf.pwr,
|
||||
conf->tx.radio_conf.mod,
|
||||
conf->tx.radio_conf.cca
|
||||
)) {
|
||||
TRACE_ERROR("BCN > Failed to transmit APRSD data");
|
||||
}
|
||||
chThdSleep(TIME_S2I(5));
|
||||
}
|
||||
|
||||
// Telemetry encoding parameter transmission
|
||||
|
|
@ -129,7 +128,7 @@ THD_FUNCTION(bcnThread, arg) {
|
|||
0,
|
||||
conf->tx.radio_conf.pwr,
|
||||
conf->tx.radio_conf.mod,
|
||||
conf->tx.radio_conf.rssi)) {
|
||||
conf->tx.radio_conf.cca)) {
|
||||
TRACE_ERROR("BCN > Failed to transmit telemetry data");
|
||||
}
|
||||
chThdSleep(TIME_S2I(5));
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ static bool transmit_image_packet(const uint8_t *image,
|
|||
0,
|
||||
conf->radio_conf.pwr,
|
||||
conf->radio_conf.mod,
|
||||
conf->radio_conf.rssi)) {
|
||||
conf->radio_conf.cca)) {
|
||||
|
||||
TRACE_ERROR("IMG > Unable to send image packet TX on radio");
|
||||
return false;
|
||||
|
|
@ -380,7 +380,7 @@ static bool transmit_image_packets(const uint8_t *image,
|
|||
0,
|
||||
conf->radio_conf.pwr,
|
||||
conf->radio_conf.mod,
|
||||
conf->radio_conf.rssi)) {
|
||||
conf->radio_conf.cca)) {
|
||||
/* Packet has been released by transmit. */
|
||||
TRACE_ERROR("IMG > Unable to send redundant image on radio");
|
||||
}
|
||||
|
|
@ -479,7 +479,7 @@ static bool transmit_image_packets(const uint8_t *image,
|
|||
0,
|
||||
conf->radio_conf.pwr,
|
||||
conf->radio_conf.mod,
|
||||
conf->radio_conf.rssi)) {
|
||||
conf->radio_conf.cca)) {
|
||||
TRACE_ERROR("IMG > Unable to send image on radio");
|
||||
/* Transmit on radio will release the packet chain. */
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ THD_FUNCTION(logThread, arg)
|
|||
0,
|
||||
conf->radio_conf.pwr,
|
||||
conf->radio_conf.mod,
|
||||
conf->radio_conf.rssi);
|
||||
conf->radio_conf.cca);
|
||||
}
|
||||
} else {
|
||||
TRACE_INFO("LOG > No log point in memory");
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ THD_FUNCTION(posThread, arg)
|
|||
0,
|
||||
conf->radio_conf.pwr,
|
||||
conf->radio_conf.mod,
|
||||
conf->radio_conf.rssi)) {
|
||||
conf->radio_conf.cca)) {
|
||||
TRACE_ERROR("POS > failed to transmit position data");
|
||||
}
|
||||
chThdSleep(TIME_S2I(5));
|
||||
|
|
@ -89,7 +89,7 @@ THD_FUNCTION(posThread, arg)
|
|||
0,
|
||||
conf_sram.aprs.base.radio_conf.pwr,
|
||||
conf_sram.aprs.base.radio_conf.mod,
|
||||
conf_sram.aprs.base.radio_conf.rssi
|
||||
conf_sram.aprs.base.radio_conf.cca
|
||||
)) {
|
||||
TRACE_ERROR("POS > Failed to transmit APRSD data");
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ THD_FUNCTION(posThread, arg)
|
|||
0,
|
||||
conf->radio_conf.pwr,
|
||||
conf->radio_conf.mod,
|
||||
conf->radio_conf.rssi)) {
|
||||
conf->radio_conf.cca)) {
|
||||
TRACE_ERROR("POS > Failed to transmit telemetry data");
|
||||
}
|
||||
chThdSleep(TIME_S2I(5));
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ void start_aprs_threads(radio_unit_t radio, radio_freq_t base_freq,
|
|||
*/
|
||||
bool transmitOnRadio(packet_t pp, radio_freq_t base_freq,
|
||||
channel_hz_t step, radio_ch_t chan,
|
||||
radio_pwr_t pwr, mod_t mod, radio_squelch_t rssi) {
|
||||
radio_pwr_t pwr, mod_t mod, radio_squelch_t cca) {
|
||||
/* TODO: This should select a radio by frequency. For now just use 1. */
|
||||
radio_unit_t radio = PKT_RADIO_1;
|
||||
|
||||
|
|
@ -135,46 +135,33 @@ bool transmitOnRadio(packet_t pp, radio_freq_t base_freq,
|
|||
return false;
|
||||
}
|
||||
|
||||
if(base_freq == FREQ_APRS_RECEIVE) {
|
||||
/* Get current RX frequency (if valid) and use that. */
|
||||
packet_svc_t *handler = pktGetServiceObject(radio);
|
||||
if(pktIsReceiveActive(radio)) {
|
||||
base_freq = handler->radio_rx_config.base_frequency;
|
||||
step = handler->radio_rx_config.step_hz;
|
||||
chan = handler->radio_rx_config.channel;
|
||||
} else
|
||||
base_freq = FREQ_APRS_DYNAMIC;
|
||||
}
|
||||
|
||||
if(base_freq == FREQ_APRS_DYNAMIC) {
|
||||
base_freq = getAPRSRegionFrequency(); // Get transmission frequency by geofencing
|
||||
step = 0;
|
||||
chan = 0;
|
||||
}
|
||||
|
||||
uint16_t len = ax25_get_info(pp, NULL);
|
||||
|
||||
/* Check information size. */
|
||||
if(AX25_MIN_INFO_LEN < len && len <= AX25_MAX_INFO_LEN) {
|
||||
/* Check frequency. */
|
||||
if(!Si446x_isFrequencyInBand(radio, base_freq, step, chan)) {
|
||||
TRACE_ERROR("RAD > Transmit base frequency of %d.%03d MHz is invalid",
|
||||
base_freq/1000000, (base_freq%1000000)/1000);
|
||||
radio_freq_t op_freq = pktComputeOperatingFrequency(radio,
|
||||
base_freq,
|
||||
step,
|
||||
chan);
|
||||
if(op_freq == FREQ_RADIO_INVALID) {
|
||||
TRACE_ERROR("RAD > Transmit operating frequency of %d.%03d MHz is invalid",
|
||||
op_freq/1000000, (op_freq%1000000)/1000);
|
||||
#if USE_NEW_PKT_TX_ALLOC == TRUE
|
||||
pktReleaseBufferChain(pp);
|
||||
#else
|
||||
ax25_delete (pp);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
radio_freq_t op_freq = pktComputeOperatingFrequency(base_freq, step, chan);
|
||||
TRACE_INFO( "RAD > %s transmit on %d.%03d MHz (ch %d),"
|
||||
" Pwr %d, %s, rssi %d, data %d",
|
||||
(pp->nextp != NULL) ? "Burst" : "Packet",
|
||||
op_freq/1000000, (op_freq%1000000)/1000,
|
||||
chan, pwr, getModulation(mod), rssi, len
|
||||
);
|
||||
TRACE_INFO( "RAD > %s transmit on %d.%03d MHz (ch %d),"
|
||||
" Pwr %d, %s, cca %d, data %d",
|
||||
(pp->nextp != NULL) ? "Burst" : "Packet",
|
||||
op_freq/1000000, (op_freq%1000000)/1000,
|
||||
chan, pwr, getModulation(mod), cca, len
|
||||
);
|
||||
|
||||
|
||||
/* Check information size. */
|
||||
if(AX25_MIN_INFO_LEN < len && len <= AX25_MAX_INFO_LEN) {
|
||||
|
||||
/* TODO: Check size of buf. */
|
||||
char buf[1024];
|
||||
|
|
@ -184,7 +171,7 @@ bool transmitOnRadio(packet_t pp, radio_freq_t base_freq,
|
|||
/* The service object. */
|
||||
packet_svc_t *handler = pktGetServiceObject(radio);
|
||||
|
||||
/* Update the saved radio data with this new request. */
|
||||
/* Get the saved radio data for this new request. */
|
||||
radio_task_object_t rt = handler->radio_tx_config;
|
||||
|
||||
rt.handler = handler;
|
||||
|
|
@ -195,7 +182,7 @@ bool transmitOnRadio(packet_t pp, radio_freq_t base_freq,
|
|||
rt.channel = chan;
|
||||
rt.tx_power = pwr;
|
||||
rt.tx_speed = (mod == MOD_2FSK ? 9600 : 1200);
|
||||
rt.squelch = rssi;
|
||||
rt.squelch = cca;
|
||||
rt.packet_out = pp;
|
||||
|
||||
/* Update the task mirror. */
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@
|
|||
#include "ch.h"
|
||||
#include "ax25_pad.h"
|
||||
|
||||
#define FREQ_APRS_DYNAMIC 0 /* Geofencing frequency (144.8 default). */
|
||||
#define FREQ_APRS_SCAN 1 /* Frequency last found in RX scan. - TBI */
|
||||
#define FREQ_APRS_RECEIVE 2 /* Active RX frequency - fall back to DYNAMIC. */
|
||||
#define FREQ_CMDC_RECEIVE 3 /* Frequency used for command and control. TBI */
|
||||
#define FREQ_RADIO_INVALID 0
|
||||
#define FREQ_APRS_DYNAMIC 1 /* Geofencing frequency (144.8 default). */
|
||||
#define FREQ_APRS_SCAN 2 /* Frequency last found in RX scan. - TBI */
|
||||
#define FREQ_APRS_RECEIVE 3 /* Active RX frequency - fall back to DYNAMIC. */
|
||||
#define FREQ_CMDC_RECEIVE 4 /* Frequency used for command and control. TBI */
|
||||
|
||||
#define CYCLE_CONTINUOUSLY 0
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ typedef struct {
|
|||
uint32_t freq; // 0: APRS region frequency (determined by geofencing), f>0 static frequency
|
||||
mod_t mod;
|
||||
uint32_t speed;
|
||||
uint8_t rssi;
|
||||
uint8_t cca;
|
||||
bool redundantTx;
|
||||
} radio_tx_conf_t; // Radio / Modulation
|
||||
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue