adding new commands

This commit is contained in:
Morgan 'ARR\!' Allen 2020-04-22 22:20:12 -07:00
parent 8785160ff5
commit cf3df53b18
5 changed files with 101 additions and 2 deletions

View file

@ -5,10 +5,12 @@
extern "C" { extern "C" {
#endif #endif
void cmd_sf_register(); void cmd_bw_register();
void cmd_cr_register(); void cmd_cr_register();
void cmd_sf_register();
void cmd_preamble_register(); void cmd_preamble_register();
void cmd_send_register(); void cmd_send_register();
void cmd_dump_register();
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1,10 +1,14 @@
set(COMPONENT_SRCS "\ set(COMPONENT_SRCS "\
main.c\ main.c\
lorcomm.c\
ble.c\
console.c\ console.c\
cmd_sf.c\ cmd_bw.c\
cmd_cr.c\ cmd_cr.c\
cmd_sf.c\
cmd_preamble.c\ cmd_preamble.c\
cmd_send.c\ cmd_send.c\
cmd_dump.c\
") ")
set(COMPONENT_ADD_INCLUDEDIRS ". ../include") set(COMPONENT_ADD_INCLUDEDIRS ". ../include")

50
main/cmd_bw.c Normal file
View file

@ -0,0 +1,50 @@
#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 *bandwidth;
struct arg_end *end;
lora32_cfg_t *lora;
} bw_args;
int set_bw(int argc, char **argv) {
if(argc == 1) {
printf(" > %d\n", bw_args.lora->bandwidth);
return 0;
}
int nerrors = arg_parse(argc, argv, (void **) &bw_args);
if (nerrors != 0) {
arg_print_errors(stderr, bw_args.end, argv[0]);
return 1;
}
lora32_set_bandwidth((lora32_cfg_t*)bw_args.lora, bw_args.bandwidth->ival[0]);
return 0;
}
void cmd_bw_register(lora32_cfg_t *lora) {
bw_args.bandwidth = arg_int0(NULL, NULL, "<bw>", "Bandwidth");
bw_args.end = arg_end(1);
bw_args.lora = lora;
const esp_console_cmd_t bw_cmd = {
.command = "bandwidth",
.help = "Set bandwidth",
.hint = NULL,
.func = &set_bw,
.argtable = &bw_args
};
ESP_ERROR_CHECK(esp_console_cmd_register(&bw_cmd));
}

33
main/cmd_dump.c Normal file
View file

@ -0,0 +1,33 @@
#include <stdio.h>
#include <string.h>
#include "esp_log.h"
#include "esp_console.h"
#include "argtable3/argtable3.h"
#include "esp32-lora.h"
static struct {
struct arg_end *end;
lora32_cfg_t *lora;
} dump_args;
int dump(int argc, char **argv) {
lora32_dump_regs((lora32_cfg_t*)dump_args.lora);
return 0;
}
void cmd_dump_register(lora32_cfg_t *lora) {
dump_args.end = arg_end(1);
dump_args.lora = lora;
const esp_console_cmd_t dump_cmd = {
.command = "dump",
.help = "Dump SX127x registers",
.hint = NULL,
.func = &dump,
.argtable = &dump_args
};
ESP_ERROR_CHECK(esp_console_cmd_register(&dump_cmd));
}

10
main/cmd_settings.c Normal file
View file

@ -0,0 +1,10 @@
#include <stdint.h>
#include "cmd_settings.h"
static struct {
struct arg_end *end;
} settings_args;
uint8_t init_settings_cmds() {
return 0;
}