more settings

This commit is contained in:
Morgan 'ARR\!' Allen 2020-02-29 15:43:15 -08:00
parent b9c865eaed
commit d5b39501fb
5 changed files with 56 additions and 1 deletions

View file

@ -7,6 +7,7 @@ extern "C" {
void cmd_sf_register(); void cmd_sf_register();
void cmd_cr_register(); void cmd_cr_register();
void cmd_preamble_register();
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1,4 +1,10 @@
set(COMPONENT_SRCS "main.c console.c cmd_sf.c cmd_cr.c") set(COMPONENT_SRCS "\
main.c\
console.c\
cmd_sf.c\
cmd_cr.c\
cmd_preamble.c\
")
set(COMPONENT_ADD_INCLUDEDIRS ". ../include") set(COMPONENT_ADD_INCLUDEDIRS ". ../include")
register_component() register_component()

45
main/cmd_preamble.c Normal file
View file

@ -0,0 +1,45 @@
#include <stdio.h>
#include <string.h>
#include "esp_log.h"
#include "esp_console.h"
#include "argtable3/argtable3.h"
#include "cmd_lora.h"
#include "esp32-lora.h"
static struct {
struct arg_int *codingrate;
struct arg_end *end;
lora32_cfg_t *lora;
} preamble_args;
int set_preamble(int argc, char **argv) {
int nerrors = arg_parse(argc, argv, (void **) &preamble_args);
if (nerrors != 0) {
arg_print_errors(stderr, preamble_args.end, argv[0]);
return 1;
}
//lora32_set_preamble((lora32_cfg_t*)preamble_args.lora, preamble_args.codingrate->ival[0]);
return 0;
}
void cmd_preamble_register(lora32_cfg_t *lora) {
preamble_args.codingrate = arg_int0(NULL, NULL, "<preamble>", "Preamble");
preamble_args.end = arg_end(1);
preamble_args.lora = lora;
const esp_console_cmd_t preamble_cmd = {
.command = "preamble",
.help = "Set preamble",
.hint = NULL,
.func = &set_preamble,
.argtable = &preamble_args
};
ESP_ERROR_CHECK(esp_console_cmd_register(&preamble_cmd));
}

View file

@ -50,6 +50,7 @@ void console_task(void *args) {
cmd_sf_register(args); cmd_sf_register(args);
cmd_cr_register(args); cmd_cr_register(args);
cmd_preamble_register(args);
const char* prompt = LOG_COLOR_I "lorcomm> " LOG_RESET_COLOR; const char* prompt = LOG_COLOR_I "lorcomm> " LOG_RESET_COLOR;

View file

@ -185,6 +185,8 @@ void app_main(void) {
xTaskCreate(console_task, "console", 4048, &lora, tskIDLE_PRIORITY + 3, NULL); xTaskCreate(console_task, "console", 4048, &lora, tskIDLE_PRIORITY + 3, NULL);
printf("%d %f\n", portTICK_PERIOD_MS, (float)(1 / portTICK_PERIOD_MS));
while(1) { while(1) {
vTaskDelay(100 / portTICK_PERIOD_MS); vTaskDelay(100 / portTICK_PERIOD_MS);
} }