Fix RSSI setting bug. Add save indicator MAGIC to config save.

pull/4/head
CInsights 2018-03-06 14:58:03 +11:00
rodzic b56968449e
commit a171afac93
8 zmienionych plików z 55 dodań i 36 usunięć

Wyświetl plik

@ -128,7 +128,7 @@ const conf_t conf_flash_default = {
.symbol = SYM_DIGIPEATER
},
.rssi = 0x48,
.rssi = 0x3F,
.dig_active = true,

Wyświetl plik

@ -12,6 +12,7 @@
#include "debug.h"
#endif
#include "pktconf.h"
#include "radio.h"
#ifdef PKT_IS_TEST_PROJECT
void ax25_delete(packet_t pp);
@ -621,10 +622,10 @@ static void Si446x_setModem2FSK(uint32_t speed)
/* ====================================================================== Radio Settings ====================================================================== */
static uint8_t Si446x_getChannel(void) {
const uint8_t state_info[] = {0x33};
uint8_t rxData[3];
Si446x_read(state_info, sizeof(state_info), rxData, 3);
uint8_t Si446x_getChannel(void) {
const uint8_t state_info[] = {Si446x_REQUEST_DEVICE_STATE};
uint8_t rxData[4];
Si446x_read(state_info, sizeof(state_info), rxData, sizeof(rxData));
return rxData[3];
}
@ -637,8 +638,8 @@ static void Si446x_writeFIFO(uint8_t *msg, uint8_t size) {
Si446x_write(write_fifo, size+1);
}
static uint8_t Si446x_freeFIFO(void) {
const uint8_t fifo_info[] = {0x15, 0x00};
static uint8_t Si446x_getTXfreeFIFO(void) {
const uint8_t fifo_info[] = {Si446x_FIFO_INFO, 0x00};
uint8_t rxData[4];
Si446x_read(fifo_info, sizeof(fifo_info), rxData, sizeof(rxData));
return rxData[3];
@ -648,8 +649,8 @@ static uint8_t Si446x_freeFIFO(void) {
static uint8_t Si446x_getState(void)
{
const uint8_t state_info[] = {0x33};
uint8_t rxData[3];
const uint8_t state_info[] = {Si446x_REQUEST_DEVICE_STATE};
uint8_t rxData[4];
Si446x_read(state_info, sizeof(state_info), rxData, sizeof(rxData));
return rxData[2] & 0xF;
}
@ -867,9 +868,11 @@ static bool Si446x_transmit(uint32_t frequency, int8_t power, uint16_t size, uin
uint16_t tot = 0;
// Wait until transceiver finishes transmission (if there is any)
while(Si446x_getState() == Si446x_STATE_TX) {
chThdSleep(TIME_MS2I(5));
if(tot++ < 2000)
chThdSleep(TIME_MS2I(10));
if(tot++ < 500)
continue;
/* Remove TX state. */
Si446x_setReadyState();
#ifdef PKT_IS_TEST_PROJECT
dbgPrintf(DBG_ERROR, "SI > Timeout waiting for TX state end\r\n");
dbgPrintf(DBG_ERROR, "SI > Attempt start of receive\r\n");
@ -877,8 +880,6 @@ static bool Si446x_transmit(uint32_t frequency, int8_t power, uint16_t size, uin
TRACE_ERROR("SI > Timeout waiting for TX state end");
TRACE_ERROR("SI > Attempt start of receive");
#endif
/* Remove TX state. */
Si446x_setReadyState();
break;
}
@ -888,10 +889,10 @@ static bool Si446x_transmit(uint32_t frequency, int8_t power, uint16_t size, uin
} else {
Si446x_shutdown();
#ifdef PKT_IS_TEST_PROJECT
dbgPrintf(DBG_ERROR, "SI > Unknown modulation\r\n");
dbgPrintf(DBG_ERROR, "SI > Modulation type not supported in receive\r\n");
dbgPrintf(DBG_ERROR, "SI > abort reception\r\n");
#else
TRACE_ERROR("SI > Modulation not supported");
TRACE_ERROR("SI > Modulation type not supported in receive");
TRACE_ERROR("SI > abort reception");
#endif
return false;
@ -933,9 +934,19 @@ static bool Si4464_restoreRX(void)
if(packetHandler) {
#ifdef PKT_IS_TEST_PROJECT
dbgPrintf(DBG_INFO, "SI > Resume packet reception\r\n");
dbgPrintf(DBG_INFO, "SI > Resume packet reception %d.%03d MHz,"
" Chn %d, Rssi %d, %s\r\n",
rx_frequency/1000000, (rx_frequency%1000000)/1000,
Si446x_getChannel(),
rx_rssi, getModulation(rx_mod);
#else
TRACE_INFO("SI > Resume packet reception");
TRACE_INFO( "SI > Resume packet reception %d.%03d MHz, Chn %d, Rssi %d, %s",
rx_frequency/1000000, (rx_frequency%1000000)/1000,
Si446x_getChannel(),
rx_rssi, getModulation(rx_mod)
);
#endif
/* Resume decoding. */
@ -1068,7 +1079,7 @@ static uint32_t Si446x_encodeDataToAFSK(uint8_t *inbuf, uint32_t inlen,
return blen;
}
static uint8_t Si446x_getUpsampledAFSKbits(uint8_t* buf, uint32_t blen)
static uint8_t Si446x_getUpsampledAFSKbits(uint8_t* buf/*, uint32_t blen*/)
{
/* This function may be called with different bit stream sources.
* These will have their own blen so checking is not valid.
@ -1142,7 +1153,7 @@ THD_FUNCTION(si_fifo_feeder_afsk, arg)
uint8_t localBuffer[Si446x_FIFO_COMBINED_SIZE];
/* Get the FIFO buffer amount currently available. */
uint8_t free = Si446x_freeFIFO();
uint8_t free = Si446x_getTXfreeFIFO();
/*
* Account for all modulation bits (round up to a byte boundary).
@ -1153,7 +1164,7 @@ THD_FUNCTION(si_fifo_feeder_afsk, arg)
// Initial FIFO fill
for(uint16_t i = 0; i < c; i++)
localBuffer[i] = Si446x_getUpsampledAFSKbits(layer0, layer0_blen);
localBuffer[i] = Si446x_getUpsampledAFSKbits(layer0/*, layer0_blen*/);
Si446x_writeFIFO(localBuffer, c);
// Start transmission
@ -1161,14 +1172,14 @@ THD_FUNCTION(si_fifo_feeder_afsk, arg)
/* Transmit started OK. */
while(c < all) { // Do while bytes not written into FIFO completely
// Determine free memory in Si446x-FIFO
uint8_t more = Si446x_freeFIFO();
uint8_t more = Si446x_getTXfreeFIFO();
if(more > all - c) {
if((more = all - c) == 0) // Calculate remainder to send
break; // End if nothing left
}
for(uint16_t i = 0; i < more; i++)
localBuffer[i] = Si446x_getUpsampledAFSKbits(layer0, layer0_blen);
localBuffer[i] = Si446x_getUpsampledAFSKbits(layer0/*, layer0_blen*/);
Si446x_writeFIFO(localBuffer, more); // Write into FIFO
c += more;
@ -1277,7 +1288,7 @@ void Si446x_startDecoder(radio_freq_t freq, radio_squelch_t sq, void* cb) {
/* Start the decoder. */
pktStartDataReception(packetHandler,
94,
0,
sq,
Si446x_mapCallback);
}

Wyświetl plik

@ -15,7 +15,7 @@
#define Si446x_CLK_OFFSET 0
#endif
// Varios macros
// Various macros
#define Si446x_getGPIO0() palReadLine(LINE_RADIO_GPIO0)
#define Si446x_getGPIO1() palReadLine(LINE_RADIO_GPIO1)
@ -46,7 +46,9 @@
#define Si446x_READ_CMD_BUFF 0x44
#define Si446x_START_TX 0x31
#define Si446x_START_RX 0x32
#define Si446x_REQUEST_DEVICE_STATE 0x33
#define Si446x_RX_HOP 0x36
#define Si446x_FIFO_INFO 0x15
/* Defined response values. */
@ -205,6 +207,7 @@ bool Si446x_receiveNoLock(uint32_t frequency, uint8_t chan,
void Si446x_unlockRadio(void);
void Si446x_lockRadioByCamera(void);
void Si446x_conditional_init(void);
uint8_t Si446x_getChannel(void);
#endif /* Si446x_CLK_OFFSET */
#endif /* __si446x__H__ */

Wyświetl plik

@ -15,6 +15,7 @@
*/
#include "pktconf.h"
#include "radio.h"
/**
* @brief Process radio task requests.
@ -90,7 +91,7 @@ THD_FUNCTION(pktRadioManager, arg) {
radio_squelch_t sq = task_object->squelch;
radio_freq_t freq = task_object->base_frequency;
radio_ch_t chan = task_object->channel;
Si446x_receiveNoLock(freq, sq, chan, MOD_AFSK);
Si446x_receiveNoLock(freq, chan, sq, MOD_AFSK);
rx_active = true;
break;
} /* End case PKT_RADIO_RX. */

Wyświetl plik

@ -149,6 +149,7 @@ msg_t pktOpenRadioService(radio_unit_t radio,
*
* @param[in] handler pointer to a @p packet handler object.
* @param[in] channel radio channel number to select
* @param[in] sq the RSSI setting to be used.
* @param[in] cb callback function called on receipt of packet.
*
* @return Status of the operation.

Wyświetl plik

@ -402,6 +402,7 @@ static bool aprs_decode_message(packet_t pp)
} else if(!strcmp(command, "?save")) { // Transmit position
TRACE_INFO("RX > Message: Save");
conf_sram.magic = CONFIG_MAGIC_UPDATED;
flashSectorBegin(flashSectorAt(0x08060000));
flashErase(0x08060000, 0x20000);
flashWrite(0x08060000, (char*)&conf_sram, sizeof(conf_t));

Wyświetl plik

@ -6,12 +6,7 @@
#include "geofence.h"
#include "aprs.h"
#include "pktconf.h"
static const char *getModulation(uint8_t key) {
const char *val[] = {"AFSK", "2FSK"};
return val[key];
};
#include "radio.h"
static void handlePacket(uint8_t *buf, uint32_t len) {
/* Remove CRC from frame. */
@ -46,6 +41,7 @@ void start_rx_thread(uint32_t freq, uint8_t rssi) {
// Start decoder
Si446x_startDecoder(freq, rssi, handlePacket);
}
bool transmitOnRadio(packet_t pp, uint32_t freq, uint8_t pwr, mod_t mod)
@ -58,9 +54,9 @@ bool transmitOnRadio(packet_t pp, uint32_t freq, uint8_t pwr, mod_t mod)
if(len) // Message length is not zero
{
TRACE_INFO( "RAD > Transmit %d.%03d MHz, Pwr %d, %s, %d byte",
freq/1000000, (freq%1000000)/1000, pwr,
getModulation(mod), len
TRACE_INFO( "RAD > Transmit %d.%03d MHz, Chn %d, Pwr %d, %s, %d byte",
freq/1000000, (freq%1000000)/1000, Si446x_getChannel(),
pwr, getModulation(mod), len
);
char buf[1024];

Wyświetl plik

@ -21,5 +21,11 @@
void start_rx_thread(uint32_t freq, uint8_t rssi);
bool transmitOnRadio(packet_t pp, uint32_t freq, uint8_t pwr, mod_t mod);
#endif
inline const char *getModulation(uint8_t key) {
const char *val[] = {"AFSK", "2FSK"};
return val[key];
};
#endif /* __RADIO_H__ */