Skip to content

Commit 7b9f858

Browse files
committed
console add help command
1 parent 63162cd commit 7b9f858

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

src/console.c

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,36 @@ static inline void strtolower(char *str) {
166166
}
167167
}
168168

169-
static void console_thread(void)
169+
static void print_help(void)
170170
{
171-
console_getline_init();
172-
while (log_data_pending())
173-
k_usleep(1);
174-
k_msleep(100);
175-
printk("*** " CONFIG_USB_DEVICE_MANUFACTURER " " CONFIG_USB_DEVICE_PRODUCT " ***\n");
176-
printk(FW_STRING);
177-
printk("info Get device information\n");
171+
printk("\nhelp Display this help text\n");
172+
173+
printk("\ninfo Get device information\n");
178174
printk("uptime Get device uptime\n");
179175
printk("list Get paired devices\n");
180176
printk("reboot Soft reset the device\n");
181-
printk("add <address> Manually add a device\n");
177+
printk("\nadd <address> Manually add a device\n");
182178
printk("remove Remove last device\n");
183179
printk("pair Enter pairing mode\n");
184180
printk("exit Exit pairing mode\n");
185181
printk("clear Clear stored devices\n");
182+
#if DFU_EXISTS
183+
printk("\ndfu Enter DFU bootloader\n");
184+
#endif
185+
printk("\nmeow Meow!\n");
186+
}
187+
188+
static void console_thread(void)
189+
{
190+
console_getline_init();
191+
while (log_data_pending())
192+
k_usleep(1);
193+
k_msleep(100);
194+
printk("*** " CONFIG_USB_DEVICE_MANUFACTURER " " CONFIG_USB_DEVICE_PRODUCT " ***\n");
195+
printk(FW_STRING);
196+
print_help();
197+
198+
const char command_help[] = "help";
186199

187200
const char command_info[] = "info";
188201
const char command_uptime[] = "uptime";
@@ -193,15 +206,9 @@ static void console_thread(void)
193206
const char command_pair[] = "pair";
194207
const char command_exit[] = "exit";
195208
const char command_clear[] = "clear";
196-
197209
#if DFU_EXISTS
198-
printk("dfu Enter DFU bootloader\n");
199-
200210
const char command_dfu[] = "dfu";
201211
#endif
202-
203-
printk("meow Meow!\n");
204-
205212
const char command_meow[] = "meow";
206213

207214
while (1) {
@@ -217,7 +224,11 @@ static void console_thread(void)
217224
strtolower(argv[1]); // lower case the first argument
218225
// only care that the first words are matchable
219226

220-
if (strcmp(line, command_info) == 0)
227+
if (strcmp(argv[0], command_help) == 0)
228+
{
229+
print_help();
230+
}
231+
else if (strcmp(argv[0], command_info) == 0)
221232
{
222233
print_info();
223234
}
@@ -261,7 +272,7 @@ static void console_thread(void)
261272
{
262273
esb_finish_pair();
263274
}
264-
else if (strcmp(line, command_clear) == 0)
275+
else if (strcmp(line, command_clear) == 0)
265276
{
266277
esb_clear();
267278
}
@@ -277,7 +288,7 @@ static void console_thread(void)
277288
#endif
278289
}
279290
#endif
280-
else if (strcmp(line, command_meow) == 0)
291+
else if (strcmp(line, command_meow) == 0)
281292
{
282293
print_meow();
283294
}

0 commit comments

Comments
 (0)