-static void
-ao_packet_echo(void) __reentrant
-{
- uint8_t c;
- while (ao_packet_enable) {
- c = ao_packet_getchar();
- if (ao_packet_enable) {
- putchar(c);
- if (c == (uint8_t) '\n')
- flush();
- }
- }
- ao_exit();
-}
-
-static __xdata struct ao_task ao_packet_echo_task;
-
-static void
-ao_packet_forward(void) __reentrant
-{
- char c;
- ao_packet_enable = 1;
- ao_cmd_white();
-
- if (ao_cmd_lex_c == 'm')
- ao_add_task(&ao_packet_task, ao_packet_master, "master");
- else
- ao_add_task(&ao_packet_task, ao_packet_slave, "slave");
- ao_add_task(&ao_packet_echo_task, ao_packet_echo, "echo");
- while ((c = getchar()) != '~')
- ao_packet_putchar(c);
- ao_packet_enable = 0;
- ao_radio_abort();
- while (ao_packet_echo_task.wchan || ao_packet_task.wchan) {
- ao_wake_task(&ao_packet_echo_task);
- ao_wake_task(&ao_packet_task);
- }
-}
-
-__code struct ao_cmds ao_packet_cmds[] = {
- { 'p', ao_packet_forward, "p {m|s} Remote packet link. m=master, s=slave" },
- { 0, ao_packet_forward, NULL },
-};
-
-void
-ao_packet_init(void)
-{
- ao_cmd_register(&ao_packet_cmds[0]);