kopia lustrzana https://github.com/DL7AD/pecanpico9
Implemented grouped transmissions
rodzic
b8a0cdce95
commit
f4625bf753
|
@ -284,10 +284,10 @@ void setPowerLevel(int8_t level) {
|
|||
Si4464_write(set_pa_pwr_lvl_property_command, 5);
|
||||
}
|
||||
|
||||
void startTx(uint16_t size, bool shutdownAfterPhDone) {
|
||||
void startTx(uint16_t size) {
|
||||
palClearLine(LINE_IO_LED1); // Set indication LED
|
||||
|
||||
uint8_t change_state_command[] = {0x31, 0x00, (shutdownAfterPhDone ? SI4464_STATE_READY : SI4464_STATE_NOCHANGE) << 4, (size >> 8) & 0x1F, size & 0xFF};
|
||||
uint8_t change_state_command[] = {0x31, 0x00, 0x30, (size >> 8) & 0x1F, size & 0xFF};
|
||||
Si4464_write(change_state_command, 5);
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ void Si4464_shutdown(void) {
|
|||
* @param shift Shift of FSK in Hz
|
||||
* @param level Transmission power level in dBm
|
||||
*/
|
||||
bool radioTune(uint32_t frequency, uint16_t shift, int8_t level, uint16_t size, bool shutdownAfterPhDone) {
|
||||
bool radioTune(uint32_t frequency, uint16_t shift, int8_t level, uint16_t size) {
|
||||
// Tracing
|
||||
TRACE_INFO("SI > Tune Si4464");
|
||||
|
||||
|
@ -325,7 +325,7 @@ bool radioTune(uint32_t frequency, uint16_t shift, int8_t level, uint16_t size,
|
|||
setShift(shift); // Set shift
|
||||
setPowerLevel(level); // Set power level
|
||||
|
||||
startTx(size, shutdownAfterPhDone);
|
||||
startTx(size);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@ void setModem2FSK(void);
|
|||
void setModem2GFSK(gfsk_conf_t* conf);
|
||||
void setDeviation(uint32_t deviation);
|
||||
void setPowerLevel(int8_t level);
|
||||
void startTx(uint16_t size, bool shutdownAfterPhDone);
|
||||
void startTx(uint16_t size);
|
||||
void stopTx(void);
|
||||
void Si4464_shutdown(void);
|
||||
bool radioTune(uint32_t frequency, uint16_t shift, int8_t level, uint16_t size, bool shutdownAfterPhDone);
|
||||
bool radioTune(uint32_t frequency, uint16_t shift, int8_t level, uint16_t size);
|
||||
void Si4464_writeFIFO(uint8_t *msg, uint8_t size);
|
||||
uint8_t Si4464_freeFIFO(void);
|
||||
uint8_t Si4464_getState(void);
|
||||
|
|
|
@ -169,7 +169,7 @@ uint32_t aprs_encode_position(uint8_t* message, mod_t mod, const aprs_conf_t *co
|
|||
/**
|
||||
* Transmit custom experimental packet
|
||||
*/
|
||||
uint32_t aprs_encode_experimental(char packetType, uint8_t* message, mod_t mod, const aprs_conf_t *config, uint8_t *data, size_t size)
|
||||
uint32_t aprs_encode_experimental(char packetType, uint8_t* message, mod_t mod, const aprs_conf_t *config, uint8_t *data, size_t size, bool noPreamble)
|
||||
{
|
||||
ax25_t packet;
|
||||
packet.data = message;
|
||||
|
@ -177,7 +177,7 @@ uint32_t aprs_encode_experimental(char packetType, uint8_t* message, mod_t mod,
|
|||
packet.mod = mod;
|
||||
|
||||
// Encode APRS header
|
||||
ax25_send_header(&packet, config->callsign, config->ssid, config->path, config->preamble);
|
||||
ax25_send_header(&packet, config->callsign, config->ssid, config->path, noPreamble ? 0 : config->preamble);
|
||||
ax25_send_string(&packet, "{{");
|
||||
ax25_send_byte(&packet, packetType);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
uint32_t aprs_encode_position(uint8_t* message, mod_t mod, const aprs_conf_t *config, trackPoint_t *trackPoint);
|
||||
uint32_t aprs_encode_telemetry_configuration(uint8_t* message, mod_t mod, const aprs_conf_t *config, const telemetry_conf_t type);
|
||||
uint32_t aprs_encode_message(uint8_t* message, mod_t mod, const aprs_conf_t *config, const char *receiver, const char *text);
|
||||
uint32_t aprs_encode_experimental(char packetType, uint8_t* message, mod_t mod, const aprs_conf_t *config, uint8_t *image, size_t size);
|
||||
uint32_t aprs_encode_experimental(char packetType, uint8_t* message, mod_t mod, const aprs_conf_t *config, uint8_t *data, size_t size, bool noPreamble);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ void initAFSK(radioMSG_t *msg) {
|
|||
// Initialize radio and tune
|
||||
Si4464_Init();
|
||||
setModemAFSK();
|
||||
radioTune(msg->freq, 0, msg->power, 0, false);
|
||||
radioTune(msg->freq, 0, msg->power, 0);
|
||||
}
|
||||
|
||||
void sendAFSK(radioMSG_t *msg) {
|
||||
|
@ -77,7 +77,7 @@ void init2GFSK(radioMSG_t *msg) {
|
|||
setModem2GFSK(msg->gfsk_conf);
|
||||
}
|
||||
|
||||
void send2GFSK(radioMSG_t *msg, bool shutdown) {
|
||||
void send2GFSK(radioMSG_t *msg) {
|
||||
uint16_t c = 64;
|
||||
uint16_t all = (msg->bin_len+7)/8;
|
||||
|
||||
|
@ -85,7 +85,7 @@ void send2GFSK(radioMSG_t *msg, bool shutdown) {
|
|||
Si4464_writeFIFO(msg->msg, c);
|
||||
|
||||
// Transmit
|
||||
radioTune(msg->freq, 0, msg->power, all, shutdown);
|
||||
radioTune(msg->freq, 0, msg->power, all);
|
||||
|
||||
while(c < all) { // Do while bytes not written into FIFO completely
|
||||
|
||||
|
@ -164,7 +164,7 @@ void initOOK(radioMSG_t *msg) {
|
|||
// Initialize radio and tune
|
||||
Si4464_Init();
|
||||
setModemOOK();
|
||||
radioTune(msg->freq, 0, msg->power, 0, false);
|
||||
radioTune(msg->freq, 0, msg->power, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -243,7 +243,7 @@ void init2FSK(radioMSG_t *msg) {
|
|||
// Initialize radio and tune
|
||||
Si4464_Init();
|
||||
setModem2FSK();
|
||||
radioTune(msg->freq, msg->fsk_conf->shift, msg->power, 0, false);
|
||||
radioTune(msg->freq, msg->fsk_conf->shift, msg->power, 0);
|
||||
}
|
||||
|
||||
void send2FSK(radioMSG_t *msg) {
|
||||
|
@ -349,7 +349,7 @@ bool transmitOnRadio(radioMSG_t *msg, bool shutdown) {
|
|||
case MOD_2GFSK:
|
||||
if(active_mod != msg->mod)
|
||||
init2GFSK(msg);
|
||||
send2GFSK(msg, shutdown);
|
||||
send2GFSK(msg);
|
||||
break;
|
||||
case MOD_AFSK:
|
||||
if(active_mod != msg->mod)
|
||||
|
|
|
@ -291,6 +291,12 @@ void encode_ssdv(const uint8_t *image, uint32_t image_len, module_conf_t* conf,
|
|||
ssdv_enc_init(&ssdv, SSDV_TYPE_NORMAL, conf->ssdv_conf.callsign, image_id, conf->ssdv_conf.quality);
|
||||
ssdv_enc_set_buffer(&ssdv, pkt);
|
||||
|
||||
// Init transmission packet
|
||||
radioMSG_t msg;
|
||||
msg.bin_len = 0;
|
||||
msg.freq = getFrequency(&conf->frequency);
|
||||
msg.power = conf->power;
|
||||
|
||||
while(true)
|
||||
{
|
||||
conf->wdg_timeout = chVTGetSystemTimeX() + S2ST(600); // TODO: Implement more sophisticated method
|
||||
|
@ -303,6 +309,8 @@ void encode_ssdv(const uint8_t *image, uint32_t image_len, module_conf_t* conf,
|
|||
|
||||
if(r <= 0)
|
||||
{
|
||||
if(conf->protocol == PROT_APRS_2GFSK || conf->protocol == PROT_APRS_AFSK) transmitOnRadio(&msg, true); // Empty buffer
|
||||
shutdownRadio();
|
||||
TRACE_ERROR("SSDV > Premature end of file");
|
||||
break;
|
||||
}
|
||||
|
@ -311,20 +319,17 @@ void encode_ssdv(const uint8_t *image, uint32_t image_len, module_conf_t* conf,
|
|||
|
||||
if(c == SSDV_EOI)
|
||||
{
|
||||
if(conf->protocol == PROT_APRS_2GFSK || conf->protocol == PROT_APRS_AFSK) transmitOnRadio(&msg, true); // Empty buffer
|
||||
shutdownRadio();
|
||||
TRACE_INFO("SSDV > ssdv_enc_get_packet said EOI");
|
||||
break;
|
||||
} else if(c != SSDV_OK) {
|
||||
if(conf->protocol == PROT_APRS_2GFSK || conf->protocol == PROT_APRS_AFSK) transmitOnRadio(&msg, true); // Empty buffer
|
||||
shutdownRadio();
|
||||
TRACE_ERROR("SSDV > ssdv_enc_get_packet failed: %i", c);
|
||||
return;
|
||||
}
|
||||
|
||||
// Transmit packet
|
||||
radioMSG_t msg;
|
||||
msg.freq = getFrequency(&conf->frequency);
|
||||
msg.power = conf->power;
|
||||
|
||||
switch(conf->protocol) {
|
||||
case PROT_APRS_2GFSK:
|
||||
case PROT_APRS_AFSK:
|
||||
|
@ -336,12 +341,17 @@ void encode_ssdv(const uint8_t *image, uint32_t image_len, module_conf_t* conf,
|
|||
for(uint16_t t=0; t<256; t++)
|
||||
pkt_base91[t] = 0;
|
||||
|
||||
// Encode packet
|
||||
TRACE_INFO("IMG > Encode APRS/SSDV packet");
|
||||
base91_encode(&pkt[1], pkt_base91, sizeof(pkt)-37); // Sync byte, CRC and FEC of SSDV not transmitted
|
||||
msg.bin_len = aprs_encode_experimental('I', msg.msg, msg.mod, &conf->aprs_conf, pkt_base91, strlen((char*)pkt_base91));
|
||||
msg.bin_len += 8 + aprs_encode_experimental('I', &msg.msg[msg.bin_len/8+1], msg.mod, &conf->aprs_conf, pkt_base91, strlen((char*)pkt_base91), msg.bin_len > 0);
|
||||
if(redudantTx)
|
||||
msg.bin_len += 8 + aprs_encode_experimental('I', &msg.msg[msg.bin_len/8+1], msg.mod, &conf->aprs_conf, pkt_base91, strlen((char*)pkt_base91), false);
|
||||
|
||||
// Transmit on radio (keep transmitter switched on if packet spacing=0ms and it isnt the last packet being sent)
|
||||
if(redudantTx) transmitOnRadio(&msg, false); // Redundant transmission
|
||||
transmitOnRadio(&msg, conf->packet_spacing != 0); // Keep transmitter switched on if next packet will be sent right away
|
||||
if(msg.bin_len > 58000 || conf->packet_spacing) { // Transmit if buffer is full or if single packet transmission activation (packet_spacing != 0)
|
||||
transmitOnRadio(&msg, true);
|
||||
msg.bin_len = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROT_SSDV_2FSK:
|
||||
|
@ -483,7 +493,7 @@ void start_image_thread(module_conf_t *conf)
|
|||
if(conf->init_delay) chThdSleepMilliseconds(conf->init_delay);
|
||||
TRACE_INFO("IMG > Startup image thread");
|
||||
chsnprintf(conf->name, sizeof(conf->name), "IMG");
|
||||
thread_t *th = chThdCreateFromHeap(NULL, THD_WORKING_AREA_SIZE(6*1024), "IMG", NORMALPRIO, imgThread, conf);
|
||||
thread_t *th = chThdCreateFromHeap(NULL, THD_WORKING_AREA_SIZE(6*1024+8191), "IMG", NORMALPRIO, imgThread, conf);
|
||||
if(!th) {
|
||||
// Print startup error, do not start watchdog for this thread
|
||||
TRACE_ERROR("IMG > Could not startup thread (not enough memory available)");
|
||||
|
|
|
@ -178,7 +178,7 @@ THD_FUNCTION(logThread, arg)
|
|||
msg.gfsk_conf = &(conf->gfsk_conf);
|
||||
|
||||
base91_encode((uint8_t*)pkt, pkt_base91, sizeof(pkt)); // Encode base 91
|
||||
msg.bin_len = aprs_encode_experimental('L', msg.msg, msg.mod, &conf->aprs_conf, pkt_base91, strlen((char*)pkt_base91)); // Encode APRS
|
||||
msg.bin_len = aprs_encode_experimental('L', msg.msg, msg.mod, &conf->aprs_conf, pkt_base91, strlen((char*)pkt_base91), false); // Encode APRS
|
||||
|
||||
transmitOnRadio(&msg, true); // Transmit packet
|
||||
break;
|
||||
|
|
|
@ -86,7 +86,7 @@ typedef struct {
|
|||
} gfsk_conf_t;
|
||||
|
||||
typedef struct { // Radio message type
|
||||
uint8_t msg[512]; // Message (data)
|
||||
uint8_t msg[8191]; // Message (data)
|
||||
uint32_t bin_len; // Binary length
|
||||
uint32_t freq; // Frequency
|
||||
int8_t power; // Power in dBm
|
||||
|
|
Ładowanie…
Reference in New Issue