Datasheet

Example: Updating apps/first/src/main.c
You can update apps/first with a custom shell command using the following code in main.c:
#include "console/console.h"
#include "shell/shell.h"
...
// Command handler prototype declaration
static int shell_test_cmd(int argc, char **argv);
// Shell command struct
static struct shell_cmd shell_test_cmd_struct = {
.sc_cmd = "test",
.sc_cmd_func = shell_test_cmd
};
...
// Implement your command handler
static int
shell_test_cmd(int argc, char **argv)
{
console_printf("Test!\n");
return 0;
}
...
// Call this before sysinit to register the command
#if MYNEWT_VAL(SHELL_TASK)
shell_cmd_register(&shell_test_cmd_struct);
#endif
#include <assert.h>
#include <string.h>
#include "os/os.h"
#include "bsp/bsp.h"
#include "hal/hal_gpio.h"
#include "sysinit/sysinit.h"
#include "console/console.h"
#include "shell/shell.h"
/* Define task stack and task object */
#define LED_TASK_PRIO (100) /* 1 = highest, 255 = lowest */
#define LED_STACK_SIZE OS_STACK_ALIGN(64)
struct os_task led_task;
os_stack_t led_task_stack[LED_STACK_SIZE];
/* LED task handler prototype declaration */
static void led_task_func(void *arg);
/* Command handler prototype declaration */
static int shell_test_cmd(int argc, char **argv);
/* Shell command struct */
© Adafruit Industries https://learn.adafruit.com/adafruit-nrf52-pro-feather Page 59 of 87