+static uint8_t ao_btm_enable;
+
+static void
+ao_btm_do_echo(void)
+{
+ int c;
+ while (ao_btm_enable) {
+ ao_arch_block_interrupts();
+ while ((c = _ao_serial_btm_pollchar()) == AO_READ_AGAIN && ao_btm_enable)
+ _ao_serial_btm_sleep_for(0);
+ ao_arch_release_interrupts();
+ if (c != AO_READ_AGAIN) {
+ putchar(c);
+ flush();
+ }
+ }
+ ao_exit();
+}
+
+static struct ao_task ao_btm_echo_task;
+
+static void
+ao_btm_send(void)
+{
+ int c;
+ ao_btm_enable = 1;
+ ao_add_task(&ao_btm_echo_task, ao_btm_do_echo, "btm-echo");
+ while ((c = getchar()) != '~') {
+ ao_serial_btm_putchar(c);
+ }
+ ao_btm_enable = 0;
+ ao_wakeup((void *) &ao_serial_btm_rx_fifo);
+}
+
+const struct ao_cmds ao_btm_cmds[] = {