aboutsummaryrefslogtreecommitdiff
path: root/projects/cli-test/cli-test.c
diff options
context:
space:
mode:
authorFredrik Thulin <fredrik@thulin.net>2016-07-09 21:53:39 +0200
committerFredrik Thulin <fredrik@thulin.net>2016-07-09 21:53:39 +0200
commit556dccb585c8e2023c35bb25d5009e36575ebd33 (patch)
tree57485316dfae50b58da0421506a1f3cbc13486b5 /projects/cli-test/cli-test.c
parentdcc6cf1b97935bc3a663714f596cacba619a8b3d (diff)
Merge more code from projects/hsm.
Diffstat (limited to 'projects/cli-test/cli-test.c')
-rw-r--r--projects/cli-test/cli-test.c49
1 files changed, 3 insertions, 46 deletions
diff --git a/projects/cli-test/cli-test.c b/projects/cli-test/cli-test.c
index 10b31a4..d04371b 100644
--- a/projects/cli-test/cli-test.c
+++ b/projects/cli-test/cli-test.c
@@ -33,6 +33,7 @@
*/
#include "stm-init.h"
#include "stm-led.h"
+#include "stm-uart.h"
#include "mgmt-cli.h"
#include "mgmt-dfu.h"
@@ -50,61 +51,17 @@
volatile uint8_t uart_rx;
-int check_auth(const char *username, const char *password)
-{
- if (strcasecmp(username, "ct") != 0)
- return CLI_ERROR;
- if (strcasecmp(password, "ct") != 0)
- return CLI_ERROR;
- return CLI_OK;
-}
-
-typedef void (*pFunction)(void);
-
-/* This is it's own function to make it more convenient to set a breakpoint at it in gdb */
-void do_early_dfu_jump(void)
-{
- pFunction loaded_app = (pFunction) *dfu_code_ptr;
- /* Set the stack pointer to the correct one for the firmware */
- __set_MSP(*dfu_msp_ptr);
- /* Set the Vector Table Offset Register */
- SCB->VTOR = (uint32_t) dfu_firmware;
- loaded_app();
- while (1);
-}
-
int
main()
{
- static struct cli_def cli;
-
- /* Check if we've just rebooted in order to jump to the firmware. */
- if (*dfu_control == HARDWARE_EARLY_DFU_JUMP) {
- *dfu_control = 0;
- do_early_dfu_jump();
- }
-
stm_init();
+ uart_set_default(STM_UART_MGMT);
- led_on(LED_RED);
-
- mgmt_cli_init(&cli);
- cli_set_auth_callback(&cli, check_auth);
-
- configure_cli_show(&cli);
- configure_cli_fpga(&cli);
- configure_cli_test(&cli);
- configure_cli_misc(&cli);
- configure_cli_dfu(&cli);
- configure_cli_keystore(&cli);
-
- led_off(LED_RED);
led_on(LED_GREEN);
while (1) {
- embedded_cli_loop(&cli);
+ cli_main();
/* embedded_cli_loop returns when the user enters 'quit' or 'exit' */
- cli_print(&cli, "\nLogging out...\n");
}
/* NOT REACHED */