diff --git a/src/teensy_dsc/cli.cpp b/src/teensy_dsc/cli.cpp index bfd2fa9..efe2335 100644 --- a/src/teensy_dsc/cli.cpp +++ b/src/teensy_dsc/cli.cpp @@ -4,7 +4,7 @@ #include "cli.h" #include "utils.h" #include "defaults.h" -#include "wifly.h" +#include "network.h" void setup_commands(cli_ctx *ctx); @@ -12,7 +12,7 @@ void setup_commands(cli_ctx *ctx); * Initalizer for a CLI context */ cli_ctx * -cli_init_cmd(AnySerial *aserial, common_cli_ctx *common, WiFlySerial *wifly) { +cli_init_cmd(AnySerial *aserial, common_cli_ctx *common, WiFly *wifly) { cli_ctx *ctx; ctx = (cli_ctx *)malloc(sizeof(cli_ctx)); @@ -22,6 +22,11 @@ cli_init_cmd(AnySerial *aserial, common_cli_ctx *common, WiFlySerial *wifly) { ctx->prev_state = NONE; ctx->serial = aserial; ctx->wifly = wifly; + if (wifly == NULL) { + ctx->eat_errors = true; + } else { + ctx->eat_errors = false; + } setup_commands(ctx); return ctx; @@ -257,7 +262,9 @@ wifi_interactive(cli_ctx *ctx) { if (pos == READBUFF_SIZE) { line[0] = NULL; pos = 0; - ctx->serial->printf("ERR: command too long\n"); + if (! ctx->eat_errors) { + ctx->serial->printf("ERR: command too long\n"); + } } } } @@ -302,13 +309,15 @@ setup_commands(cli_ctx *ctx) { */ cmd_status wifi_ap_commands(cli_ctx *ctx, const char *args) { - if (strcmp(args, "ON") == 0) { - wifi_initial_setup(ctx->wifly, ctx->common->network); - } else if (strcmp(args, "OFF") == 0) { - // TODO: do something - ctx->serial->printf("Doh, this command doesn't do anything yet!\n"); + if (strcmp(args, "SAVE") == 0) { + wifi_configure(ctx->wifly, ctx->common->network); + ctx->serial->printf("OK\n"); } else if (strcmp(args, "SHOW") == 0) { wifi_get_config(ctx->wifly, ctx->serial); + ctx->serial->printf("OK\n"); + } else if (strcmp(args, "RESET") == 0) { + ctx->wifly->reset(); + ctx->serial->printf("OK\n"); } else { return E_CMD_NOT_FOUND; } @@ -321,18 +330,26 @@ wifi_ap_commands(cli_ctx *ctx, const char *args) { cmd_status wifi_get_help(cli_ctx *ctx, const char *args) { ctx->serial->printf( -F("AP ON => Turn on the WiFi access point\n" \ -"AP OFF => Turn off the WiFi access point\n" \ +F("AP SAVE => Save WiFi access point config\n" \ "AP SHOW => Shows the WiFi configuration\n" \ +"AP RESET => Reset WiFi to factory defaults\n" \ "SET SSID => Set the WiFi SSID\n" \ "SET PASS => Set the WiFi passphrase\n" \ "SET IP => Set the WiFi IP address\n" \ "SET MASK => Set the WiFi netmask\n" \ "SET CHAN => Set the WiFi channel [0-12]\n" \ "SET PORT => Set the TCP PORT [1-65535]\n" \ +"SET RATE => Set the WiFi rate [0-15]\n" \ +"SET TXP => Set the WiFi TX Power [0-12]\n" \ "SET AUTH [WPA2|OPEN] => Enable WPA2-PSK or no security\n" \ +"SET MODE [AP|CLIENT] => Enable AP or client mode\n" \ +"SET ALT xxxx => set ALT encoder resolution\n" \ +"SET AZ xxxx => set AZ encoder resolution\n" \ "GET