kopia lustrzana https://github.com/DL7AD/pecanpico10
Re-implement CLI aprs_message command.
rodzic
e3fe666e4f
commit
125bbaf7df
|
@ -264,7 +264,8 @@ CPPWARN = -Wall -Wextra -Wundef
|
|||
|
||||
# List all user C define here, like -D_DEBUG=1
|
||||
UDEFS = -D_GNU_SOURCE -DARM_MATH_CM4 -DSHELL_CMD_TEST_ENABLED=1 \
|
||||
-DSHELL_CMD_EXIT_ENABLED=1 -DUSB_TRACE_LEVEL=4
|
||||
-DSHELL_CMD_EXIT_ENABLED=1 -DUSB_TRACE_LEVEL=4 \
|
||||
-DSHELL_USE_COMPLETION=1 -DSHELL_USE_HISTORY=1
|
||||
|
||||
# Define ASM defines here
|
||||
UADEFS =
|
||||
|
|
|
@ -11,7 +11,7 @@ const conf_t conf_flash_default = {
|
|||
// Primary position transmission thread
|
||||
.pos_pri = {
|
||||
.thread_conf = {
|
||||
.active = true,
|
||||
.active = false,
|
||||
.cycle = TIME_S2I(900),
|
||||
.init_delay = TIME_S2I(5)
|
||||
},
|
||||
|
@ -54,7 +54,7 @@ const conf_t conf_flash_default = {
|
|||
// Primary image transmission thread
|
||||
.img_pri = {
|
||||
.thread_conf = {
|
||||
.active = true,
|
||||
.active = false,
|
||||
.cycle = TIME_S2I(600),
|
||||
.init_delay = TIME_S2I(20),
|
||||
.packet_spacing = TIME_S2I(1)
|
||||
|
|
|
@ -978,6 +978,7 @@ void vsync_cb(void *arg) {
|
|||
void OV5640_lockResourcesForCapture(void) {
|
||||
I2C_Lock();
|
||||
pktAcquireRadio(PKT_RADIO_1, TIME_INFINITE);
|
||||
/* FIXME: USB has to be locked. */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -986,7 +987,7 @@ void OV5640_lockResourcesForCapture(void) {
|
|||
void OV5640_unlockResourcesForCapture(void) {
|
||||
I2C_Unlock();
|
||||
pktReleaseRadio(PKT_RADIO_1);
|
||||
|
||||
/* FIXME: USB has to be unlocked. */
|
||||
}
|
||||
|
||||
uint32_t OV5640_Capture(uint8_t* buffer, uint32_t size)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "shell.h"
|
||||
#include "debug.h"
|
||||
#include <stdlib.h>
|
||||
#include "ctype.h"
|
||||
#include "image.h"
|
||||
#include "aprs.h"
|
||||
#include "radio.h"
|
||||
|
@ -18,6 +19,7 @@ const ShellCommand commands[] = {
|
|||
{"print_log", usb_cmd_printLog},
|
||||
{"config", usb_cmd_printConfig},
|
||||
{"aprs_message", usb_cmd_send_aprs_message},
|
||||
{"msg", usb_cmd_send_aprs_message}, /* Short form alias. */
|
||||
{"test_gps", usb_cmd_set_test_gps},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
@ -48,6 +50,7 @@ void usb_cmd_set_trace_level(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
usb_trace_level = atoi(argv[0]);
|
||||
}
|
||||
|
||||
|
@ -181,34 +184,51 @@ void usb_cmd_printConfig(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
|
||||
void usb_cmd_send_aprs_message(BaseSequentialStream *chp, int argc, char *argv[])
|
||||
{
|
||||
/* if(argc < 2)
|
||||
if(argc < 2)
|
||||
{
|
||||
chprintf(chp, "Argument missing!\r\n");
|
||||
chprintf(chp, "Argument 1: Destination\r\n");
|
||||
chprintf(chp, "Argument 2: Message\r\n");
|
||||
return;
|
||||
}
|
||||
chprintf(chp, "Destination: %s\r\n", argv[0]);
|
||||
chprintf(chp, "Message: %s\r\n", argv[1]);
|
||||
|
||||
packet_t packet = aprs_encode_message(conf_sram.rx.call,
|
||||
conf_sram.rx.path,
|
||||
argv[0], argv[1], false);
|
||||
char *s = argv[0];
|
||||
while(*s) {
|
||||
*s = toupper((uint8_t) *s);
|
||||
s++;
|
||||
}
|
||||
|
||||
chprintf(chp, "Destination: %s\r\n", argv[0]);
|
||||
|
||||
char m[50] = {'\0'};
|
||||
for(uint8_t i = 1; i < argc; i++) {
|
||||
strcat(m, argv[i]);
|
||||
if(i < argc - 1)
|
||||
strcat(m, (char *)" ");
|
||||
}
|
||||
|
||||
chprintf(chp, "Message: %s\r\n", m);
|
||||
|
||||
/* Send without ack request (last arg false). */
|
||||
packet_t packet = aprs_encode_message(conf_sram.aprs.tx.call,
|
||||
conf_sram.aprs.tx.path,
|
||||
argv[0], m, false);
|
||||
if(packet == NULL) {
|
||||
TRACE_WARN("CMD > No free packet objects");
|
||||
return;
|
||||
}
|
||||
transmitOnRadio(packet,
|
||||
conf_sram.rx.radio_conf.freq,
|
||||
conf_sram.rx.radio_conf.step0,
|
||||
conf_sram.rx.radio_conf.chan0,
|
||||
conf_sram.rx.radio_conf.pwr,
|
||||
conf_sram.rx.radio_conf.mod);
|
||||
|
||||
chprintf(chp, "Message sent!\r\n");*/
|
||||
conf_sram.aprs.tx.radio_conf.freq,
|
||||
0,
|
||||
0,
|
||||
conf_sram.aprs.tx.radio_conf.pwr,
|
||||
conf_sram.aprs.tx.radio_conf.mod,
|
||||
conf_sram.aprs.tx.radio_conf.rssi);
|
||||
|
||||
chprintf(chp, "Message sent!\r\n");
|
||||
/*
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
chprintf(chp, "TODO: Not implemented\r\n");
|
||||
chprintf(chp, "TODO: Not implemented\r\n");*/
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void startUSB(void) {
|
|||
void manageShell(void) {
|
||||
if(shelltp == NULL) {
|
||||
shelltp = chThdCreateFromHeap(NULL,
|
||||
THD_WORKING_AREA_SIZE(2048),
|
||||
THD_WORKING_AREA_SIZE(4*1024),
|
||||
"shell", NORMALPRIO + 1,
|
||||
shellThread,
|
||||
(void*)&shell_cfg);
|
||||
|
|
|
@ -282,6 +282,10 @@ packet_t ax25_new (void) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note this sets the nextp link to NULL.
|
||||
* If removing the memset then set nextp to NULL explicitly.
|
||||
*/
|
||||
memset(this_p, 0, sizeof(struct packet_s));
|
||||
|
||||
this_p->magic1 = MAGIC;
|
||||
|
|
|
@ -133,6 +133,7 @@ typedef struct packet_s {
|
|||
/*
|
||||
* Pass the radio parameters and radio ID.
|
||||
* This enables multiple send requests to be queued with their own data.
|
||||
* TODO: Will be deprecated as TX will be passed radio object with ref to pp
|
||||
*/
|
||||
radio_unit_t radio;
|
||||
radio_freq_t base_frequency;
|
||||
|
@ -141,6 +142,8 @@ typedef struct packet_s {
|
|||
radio_pwr_t radio_pwr;
|
||||
radio_squelch_t cca_rssi;
|
||||
uint16_t preamble_size;
|
||||
//===========================
|
||||
|
||||
uint8_t tx_seq;
|
||||
/* TODO: Set size of name with definition. */
|
||||
char tx_thd_name[16];
|
||||
|
|
|
@ -59,6 +59,7 @@ const conf_command_t command_list[] = {
|
|||
{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 },
|
||||
{TYPE_INT, "pos_pri.aprs_msg", sizeof(conf_sram.pos_pri.aprs_msg), &conf_sram.pos_pri.aprs_msg },
|
||||
{TYPE_TIME, "pos_pri.tel_enc_cycle", sizeof(conf_sram.pos_pri.tel_enc_cycle), &conf_sram.pos_pri.tel_enc_cycle },
|
||||
|
||||
{TYPE_INT, "pos_sec.active", sizeof(conf_sram.pos_sec.thread_conf.active), &conf_sram.pos_sec.thread_conf.active },
|
||||
|
@ -77,6 +78,7 @@ const conf_command_t command_list[] = {
|
|||
{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 },
|
||||
{TYPE_INT, "pos_sec.aprs_msg", sizeof(conf_sram.pos_sec.aprs_msg), &conf_sram.pos_sec.aprs_msg },
|
||||
{TYPE_TIME, "pos_sec.tel_enc_cycle", sizeof(conf_sram.pos_sec.tel_enc_cycle), &conf_sram.pos_sec.tel_enc_cycle },
|
||||
|
||||
{TYPE_INT, "img_pri.active", sizeof(conf_sram.img_pri.thread_conf.active), &conf_sram.img_pri.thread_conf.active },
|
||||
|
@ -347,7 +349,9 @@ static bool aprs_decode_message(packet_t pp)
|
|||
memset(msg_id_rx, 0, sizeof(msg_id_rx));
|
||||
|
||||
// Cut off control chars
|
||||
/* FIXME: Limit processing to size of incoming message. */
|
||||
for(uint16_t i=11; pinfo[i] != 0 && i<0xFFFF; i++) {
|
||||
/* FIXME: Trim trailing spaces before {. */
|
||||
if(pinfo[i] == '{') {
|
||||
// Copy ACK ID
|
||||
memcpy(msg_id_rx, &pinfo[i+1], sizeof(msg_id_rx)-1);
|
||||
|
@ -365,10 +369,12 @@ static bool aprs_decode_message(packet_t pp)
|
|||
}
|
||||
}
|
||||
|
||||
// Trace
|
||||
TRACE_INFO("RX > Received message from %s (ID=%s): %s", src, msg_id_rx, &pinfo[11]);
|
||||
|
||||
char *command = strlwr((char*)&pinfo[11]);
|
||||
char *command = strlwr((char*)&pinfo[11]);
|
||||
|
||||
// Trace
|
||||
TRACE_INFO("RX > Received message from %s (ID=%s): %s [%s]",
|
||||
src, msg_id_rx, &pinfo[11], command);
|
||||
|
||||
// Do control actions
|
||||
if(!strcmp(command, "?gpio pa8:1")) { // Switch on pin
|
||||
|
@ -513,7 +519,7 @@ static bool aprs_decode_message(packet_t pp)
|
|||
if(msg_id_rx[0]) { // Message ID has been sent which has to be acknowledged
|
||||
char buf[16];
|
||||
chsnprintf(buf, sizeof(buf), "ack%s", msg_id_rx);
|
||||
/* FIXME: Calls getting packet_t need to check for NULL result. */
|
||||
|
||||
packet_t pp = aprs_encode_message(conf_sram.aprs.tx.call, conf_sram.aprs.tx.path, src, buf, true);
|
||||
if(pp == NULL) {
|
||||
TRACE_WARN("RX > No free packet objects");
|
||||
|
|
|
@ -415,6 +415,7 @@ static bool transmit_image_packets(const uint8_t *image,
|
|||
// Sync byte, CRC and FEC of SSDV not transmitted (because its not necessary inside an APRS packet)
|
||||
base91_encode(&pkt[6], pkt_base91, 174);
|
||||
|
||||
/* TODO: Implement en bloc send using chained buffers. */
|
||||
packet_t packet = aprs_encode_data_packet(conf->call, conf->path, 'I', pkt_base91);
|
||||
if(packet == NULL) {
|
||||
TRACE_ERROR("IMG > No available packet for image transmission");
|
||||
|
|
Ładowanie…
Reference in New Issue