diff --git a/tracker/software/config.c b/tracker/software/config.c index 3589031f..98882c33 100644 --- a/tracker/software/config.c +++ b/tracker/software/config.c @@ -56,9 +56,9 @@ const conf_t conf_flash_default = { .img_pri = { .thread_conf = { .active = true, - .cycle = TIME_S2I(120), - .init_delay = TIME_S2I(120), - .send_spacing = TIME_MS2I(50) + .cycle = TIME_S2I(60), + .init_delay = TIME_S2I(2*60), + .send_spacing = TIME_S2I(5) }, .radio_conf = { .pwr = 0x7F, diff --git a/tracker/software/pkt/devices/si446x.c b/tracker/software/pkt/devices/si446x.c index 68e0dd30..170cd7bc 100644 --- a/tracker/software/pkt/devices/si446x.c +++ b/tracker/software/pkt/devices/si446x.c @@ -996,10 +996,10 @@ THD_FUNCTION(bloc_si_fifo_feeder_afsk, arg) { pp = np; } while(pp != NULL); + /* Save status in case a callback requires it. */ rto->result = exit_msg; - //chThdSleep(TIME_MS2I(100)); - /* Schedule thread memory release. */ + /* Finished send so schedule thread memory and task object release. */ pktScheduleSendComplete(rto, chThdGetSelfX()); /* Exit thread. */ @@ -1199,27 +1199,26 @@ THD_FUNCTION(bloc_si_fifo_feeder_fsk, arg) { } /* Get the next linked packet to send. */ packet_t np = pp->nextp; - if(exit_msg == MSG_OK) { + if(exit_msg == MSG_OK) { - /* Send was OK. Release the just completed packet. */ - pktReleaseSendObject(pp); - } else { - /* Send failed so release any queue and terminate. */ - pktReleaseBufferChain(pp); - np = NULL; - } + /* Send was OK. Release the just completed packet. */ + pktReleaseSendObject(pp); + } else { + /* Send failed so release any queue and terminate. */ + pktReleaseBufferChain(pp); + np = NULL; + } - /* No CCA on subsequent packet sends. */ - rssi = PKT_SI446X_NO_CCA_RSSI; - /* Process next packet. */ - pp = np; - } while(pp != NULL); - - //chThdSleep(TIME_MS2I(100)); - /* Finished send so schedule thread memory and task object release. */ + /* No CCA on subsequent packet sends. */ + rssi = PKT_SI446X_NO_CCA_RSSI; + /* Process next packet. */ + pp = np; + } while(pp != NULL); + /* Save status in case a callback requires it. */ rto->result = exit_msg; + /* Finished send so schedule thread memory and task object release. */ pktScheduleSendComplete(rto, chThdGetSelfX()); /* Exit thread. */ diff --git a/tracker/software/pkt/managers/pktradio.c b/tracker/software/pkt/managers/pktradio.c index c28df2dc..6c14e50b 100644 --- a/tracker/software/pkt/managers/pktradio.c +++ b/tracker/software/pkt/managers/pktradio.c @@ -181,8 +181,13 @@ THD_FUNCTION(pktRadioManager, arg) { ++handler->radio_tx_config.tx_seq_num; if(pktLLDsendPacket(task_object)) { - /* TODO: Deprecate this gear shift stuff. */ + /* + * Keep count of active sends. + * Shutdown or resume receive when all done. + */ handler->tx_count++; + + /* TODO: Deprecate this gear shift stuff. */ poll_hysteresis = PKT_RADIO_TASK_MANAGER_TX_HYSTERESIS; poll_rate = PKT_RADIO_TASK_MANAGER_TX_RATE_MS; /* Send Successfully enqueued. diff --git a/tracker/software/protocols/packet/aprs.c b/tracker/software/protocols/packet/aprs.c index 86c67c1b..274157b2 100644 --- a/tracker/software/protocols/packet/aprs.c +++ b/tracker/software/protocols/packet/aprs.c @@ -45,7 +45,7 @@ static bool dedupe_initialized; const conf_command_t command_list[] = { {TYPE_INT, "pos_pri.active", sizeof(conf_sram.pos_pri.thread_conf.active), &conf_sram.pos_pri.thread_conf.active }, {TYPE_TIME, "pos_pri.init_delay", sizeof(conf_sram.pos_pri.thread_conf.init_delay), &conf_sram.pos_pri.thread_conf.init_delay }, - {TYPE_TIME, "pos_pri.packet_spacing", sizeof(conf_sram.pos_pri.thread_conf.send_spacing), &conf_sram.pos_pri.thread_conf.send_spacing }, + {TYPE_TIME, "pos_pri.send_spacing", sizeof(conf_sram.pos_pri.thread_conf.send_spacing), &conf_sram.pos_pri.thread_conf.send_spacing }, {TYPE_INT, "pos_pri.sleep_conf.type", sizeof(conf_sram.pos_pri.thread_conf.sleep_conf.type), &conf_sram.pos_pri.thread_conf.sleep_conf.type }, {TYPE_INT, "pos_pri.sleep_conf.vbat_thres", sizeof(conf_sram.pos_pri.thread_conf.sleep_conf.vbat_thres), &conf_sram.pos_pri.thread_conf.sleep_conf.vbat_thres}, {TYPE_INT, "pos_pri.sleep_conf.vsol_thres", sizeof(conf_sram.pos_pri.thread_conf.sleep_conf.vsol_thres), &conf_sram.pos_pri.thread_conf.sleep_conf.vsol_thres}, @@ -64,7 +64,7 @@ const conf_command_t command_list[] = { {TYPE_INT, "pos_sec.active", sizeof(conf_sram.pos_sec.thread_conf.active), &conf_sram.pos_sec.thread_conf.active }, {TYPE_TIME, "pos_sec.init_delay", sizeof(conf_sram.pos_sec.thread_conf.init_delay), &conf_sram.pos_sec.thread_conf.init_delay }, - {TYPE_TIME, "pos_sec.packet_spacing", sizeof(conf_sram.pos_sec.thread_conf.send_spacing), &conf_sram.pos_sec.thread_conf.send_spacing }, + {TYPE_TIME, "pos_sec.send_spacing", sizeof(conf_sram.pos_sec.thread_conf.send_spacing), &conf_sram.pos_sec.thread_conf.send_spacing }, {TYPE_INT, "pos_sec.sleep_conf.type", sizeof(conf_sram.pos_sec.thread_conf.sleep_conf.type), &conf_sram.pos_sec.thread_conf.sleep_conf.type }, {TYPE_INT, "pos_sec.sleep_conf.vbat_thres", sizeof(conf_sram.pos_sec.thread_conf.sleep_conf.vbat_thres), &conf_sram.pos_sec.thread_conf.sleep_conf.vbat_thres}, {TYPE_INT, "pos_sec.sleep_conf.vsol_thres", sizeof(conf_sram.pos_sec.thread_conf.sleep_conf.vsol_thres), &conf_sram.pos_sec.thread_conf.sleep_conf.vsol_thres}, @@ -83,7 +83,7 @@ const conf_command_t command_list[] = { {TYPE_INT, "img_pri.active", sizeof(conf_sram.img_pri.thread_conf.active), &conf_sram.img_pri.thread_conf.active }, {TYPE_TIME, "img_pri.init_delay", sizeof(conf_sram.img_pri.thread_conf.init_delay), &conf_sram.img_pri.thread_conf.init_delay }, - {TYPE_TIME, "img_pri.packet_spacing", sizeof(conf_sram.img_pri.thread_conf.send_spacing), &conf_sram.img_pri.thread_conf.send_spacing }, + {TYPE_TIME, "img_pri.send_spacing", sizeof(conf_sram.img_pri.thread_conf.send_spacing), &conf_sram.img_pri.thread_conf.send_spacing }, {TYPE_INT, "img_pri.sleep_conf.type", sizeof(conf_sram.img_pri.thread_conf.sleep_conf.type), &conf_sram.img_pri.thread_conf.sleep_conf.type }, {TYPE_INT, "img_pri.sleep_conf.vbat_thres", sizeof(conf_sram.img_pri.thread_conf.sleep_conf.vbat_thres), &conf_sram.img_pri.thread_conf.sleep_conf.vbat_thres}, {TYPE_INT, "img_pri.sleep_conf.vsol_thres", sizeof(conf_sram.img_pri.thread_conf.sleep_conf.vsol_thres), &conf_sram.img_pri.thread_conf.sleep_conf.vsol_thres}, @@ -102,7 +102,7 @@ const conf_command_t command_list[] = { {TYPE_INT, "img_sec.active", sizeof(conf_sram.img_sec.thread_conf.active), &conf_sram.img_sec.thread_conf.active }, {TYPE_TIME, "img_sec.init_delay", sizeof(conf_sram.img_sec.thread_conf.init_delay), &conf_sram.img_sec.thread_conf.init_delay }, - {TYPE_TIME, "img_sec.packet_spacing", sizeof(conf_sram.img_sec.thread_conf.send_spacing), &conf_sram.img_sec.thread_conf.send_spacing }, + {TYPE_TIME, "img_sec.send_spacing", sizeof(conf_sram.img_sec.thread_conf.send_spacing), &conf_sram.img_sec.thread_conf.send_spacing }, {TYPE_INT, "img_sec.sleep_conf.type", sizeof(conf_sram.img_sec.thread_conf.sleep_conf.type), &conf_sram.img_sec.thread_conf.sleep_conf.type }, {TYPE_INT, "img_sec.sleep_conf.vbat_thres", sizeof(conf_sram.img_sec.thread_conf.sleep_conf.vbat_thres), &conf_sram.img_sec.thread_conf.sleep_conf.vbat_thres}, {TYPE_INT, "img_sec.sleep_conf.vsol_thres", sizeof(conf_sram.img_sec.thread_conf.sleep_conf.vsol_thres), &conf_sram.img_sec.thread_conf.sleep_conf.vsol_thres}, @@ -121,7 +121,7 @@ const conf_command_t command_list[] = { {TYPE_INT, "log.active", sizeof(conf_sram.log.thread_conf.active), &conf_sram.log.thread_conf.active }, {TYPE_TIME, "log.init_delay", sizeof(conf_sram.log.thread_conf.init_delay), &conf_sram.log.thread_conf.init_delay }, - {TYPE_TIME, "log.packet_spacing", sizeof(conf_sram.log.thread_conf.send_spacing), &conf_sram.log.thread_conf.send_spacing }, + {TYPE_TIME, "log.send_spacing", sizeof(conf_sram.log.thread_conf.send_spacing), &conf_sram.log.thread_conf.send_spacing }, {TYPE_INT, "log.sleep_conf.type", sizeof(conf_sram.log.thread_conf.sleep_conf.type), &conf_sram.log.thread_conf.sleep_conf.type }, {TYPE_INT, "log.sleep_conf.vbat_thres", sizeof(conf_sram.log.thread_conf.sleep_conf.vbat_thres), &conf_sram.log.thread_conf.sleep_conf.vbat_thres }, {TYPE_INT, "log.sleep_conf.vsol_thres", sizeof(conf_sram.log.thread_conf.sleep_conf.vsol_thres), &conf_sram.log.thread_conf.sleep_conf.vsol_thres }, diff --git a/tracker/software/threads/rxtx/image.c b/tracker/software/threads/rxtx/image.c index cfc97fa6..0286af10 100644 --- a/tracker/software/threads/rxtx/image.c +++ b/tracker/software/threads/rxtx/image.c @@ -477,9 +477,13 @@ static bool transmit_image_packets(const uint8_t *image, conf->radio_conf.rssi)) { TRACE_ERROR("IMG > Unable to send image on radio"); /* Transmit on radio will release the packet chain. */ + } else { + // Packet spacing (delay) + if(conf->thread_conf.send_spacing) + chThdSleep(conf->thread_conf.send_spacing); } } - chThdSleep(TIME_MS2I(10)); // Leave other threads some time + chThdSleep(TIME_MS2I(10)); // Leave other threads some time } /* End while(c!= SSDV_EOI) */ // Repeat packets @@ -492,13 +496,9 @@ static bool transmit_image_packets(const uint8_t *image, packetRepeats[i].n_done = false; // Set done } } - chThdSleep(TIME_MS2I(100)); // Leave other threads some time + chThdSleep(TIME_MS2I(10)); // Leave other threads some time } - // Packet spacing (delay) - if(conf->thread_conf.send_spacing) - chThdSleep(conf->thread_conf.send_spacing); - // Handle image rejection flag if((conf == &conf_sram.img_pri) && reject_pri) { // Image rejected reject_pri = false;