-__code struct ao_cmds ao_radio_cmac_cmds[] = {
- { ao_radio_cmac_key, "k <byte> ...\0Set AES-CMAC key." },
- { ao_radio_cmac_send, "s <length>\0Send AES-CMAC packet. Bytes to send follow on next line" },
- { ao_radio_cmac_recv, "S <length> <timeout>\0Receive AES-CMAC packet. Timeout in ms" },
+static void
+launch_arm(void) __reentrant
+{
+ command.tick = ao_time() - tick_offset;
+ command.serial = launch_serial;
+ command.cmd = AO_LAUNCH_ARM;
+ command.channel = launch_channel;
+ ao_radio_cmac_send(&command, sizeof (command));
+}
+
+static void
+launch_ignite(void) __reentrant
+{
+ command.tick = ao_time() - tick_offset;
+ command.serial = launch_serial;
+ command.cmd = AO_LAUNCH_FIRE;
+ command.channel = 0;
+ ao_radio_cmac_send(&command, sizeof (command));
+}
+
+static void
+launch_fire_cmd(void) __reentrant
+{
+ static __xdata struct ao_launch_command command;
+ uint8_t secs;
+ uint8_t i;
+ int8_t r;
+
+ launch_args();
+ ao_cmd_decimal();
+ secs = ao_cmd_lex_i;
+ if (ao_cmd_status != ao_cmd_success)
+ return;
+ r = launch_query();
+ if (r != AO_RADIO_CMAC_OK) {
+ printf("query failed %d\n", r);
+ return;
+ }
+
+ for (i = 0; i < 4; i++) {
+ printf("arm %d\n", i); flush();
+ launch_arm();
+ }
+
+ secs = secs * 10 - 5;
+ if (secs > 100)
+ secs = 100;
+ for (i = 0; i < secs; i++) {
+ printf("fire %d\n", i); flush();
+ launch_ignite();
+ ao_delay(AO_MS_TO_TICKS(100));
+ }
+}
+
+static void
+launch_arm_cmd(void) __reentrant
+{
+ uint8_t i;
+ int8_t r;
+ launch_args();
+ r = launch_query();
+ if (r != AO_RADIO_CMAC_OK) {
+ printf("query failed %d\n", r);
+ return;
+ }
+ for (i = 0; i < 4; i++)
+ launch_arm();
+}
+
+static void
+launch_ignite_cmd(void) __reentrant
+{
+ uint8_t i;
+ launch_args();
+ for (i = 0; i < 4; i++)
+ launch_ignite();
+}
+
+static __code struct ao_cmds ao_radio_cmac_cmds[] = {
+ { radio_cmac_send_cmd, "s <length>\0Send AES-CMAC packet. Bytes to send follow on next line" },
+ { radio_cmac_recv_cmd, "S <length> <timeout>\0Receive AES-CMAC packet. Timeout in ms" },
+ { launch_report_cmd, "l <serial> <channel>\0Get remote launch status" },
+ { launch_fire_cmd, "f <serial> <channel> <secs>\0Fire remote igniter" },
+ { launch_arm_cmd, "a <serial> <channel>\0Arm remote igniter" },
+ { launch_ignite_cmd, "i <serial> <channel>\0Pulse remote igniter" },