2 * Copyright © 2009 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 #include <ao_config.h>
22 #include <ao_sample.h>
29 #include <ao_tracker.h>
32 __xdata struct ao_config ao_config;
33 __pdata uint8_t ao_config_loaded;
34 __pdata uint8_t ao_config_dirty;
35 __xdata uint8_t ao_config_mutex;
37 #ifndef AO_CONFIG_DEFAULT_APRS_INTERVAL
38 #define AO_CONFIG_DEFAULT_APRS_INTERVAL 0
40 #define AO_CONFIG_DEFAULT_MAIN_DEPLOY 250
41 #define AO_CONFIG_DEFAULT_RADIO_CHANNEL 0
42 #define AO_CONFIG_DEFAULT_CALLSIGN "N0CALL"
43 #define AO_CONFIG_DEFAULT_ACCEL_ZERO_G 16000
44 #define AO_CONFIG_DEFAULT_APOGEE_DELAY 0
45 #define AO_CONFIG_DEFAULT_IGNITE_MODE AO_IGNITE_MODE_DUAL
46 #define AO_CONFIG_DEFAULT_PAD_ORIENTATION AO_PAD_ORIENTATION_ANTENNA_UP
47 #define AO_CONFIG_DEFAULT_PYRO_TIME AO_MS_TO_TICKS(50)
49 #ifndef USE_INTERNAL_FLASH
50 #error Please define USE_INTERNAL_FLASH
54 #ifndef AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX
55 # if FLIGHT_LOG_APPEND
56 # define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX ao_storage_log_max
58 # if USE_INTERNAL_FLASH
59 # define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX ao_storage_config
61 # define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX ((uint32_t) 192 * (uint32_t) 1024)
66 #ifndef AO_CONFIG_DEFAULT_RADIO_POWER
67 #define AO_CONFIG_DEFAULT_RADIO_POWER 0x60
69 #define AO_CONFIG_DEFAULT_RADIO_AMP 0
70 #define AO_CONFIG_DEFAULT_APRS_SSID (ao_serial_number % 10)
71 #define AO_CONFIG_DEFAULT_RADIO_RATE AO_RADIO_RATE_38400
79 ao_config_write(0, &ao_config, sizeof (ao_config));
81 ao_log_write_erase(0);
89 ao_mutex_get(&ao_config_mutex);
91 ao_mutex_put(&ao_config_mutex);
98 __xdata uint32_t ao_send_radio_setting;
102 ao_config_set_radio(void)
104 ao_config.radio_setting = ao_freq_to_set(ao_config.frequency, ao_config.radio_cal);
105 #if HAS_RADIO_FORWARD
106 ao_send_radio_setting = ao_freq_to_set(ao_config.send_frequency, ao_config.radio_cal);
109 #endif /* HAS_RADIO */
116 if (ao_config_loaded)
119 /* Yes, I know ao_storage_read calls ao_storage_setup,
120 * but ao_storage_setup *also* sets ao_storage_config, which we
121 * need before calling ao_storage_read here
124 ao_config_read(0, &ao_config, sizeof (ao_config));
126 if (ao_config.major != AO_CONFIG_MAJOR) {
127 ao_config.major = AO_CONFIG_MAJOR;
130 /* Version 0 stuff */
131 ao_config.main_deploy = AO_CONFIG_DEFAULT_MAIN_DEPLOY;
132 ao_xmemset(&ao_config.callsign, '\0', sizeof (ao_config.callsign));
133 ao_xmemcpy(&ao_config.callsign, CODE_TO_XDATA(AO_CONFIG_DEFAULT_CALLSIGN),
134 sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
135 ao_config._legacy_radio_channel = 0;
137 minor = ao_config.minor;
138 if (minor != AO_CONFIG_MINOR) {
139 /* Fixups for minor version 1 */
141 ao_config.apogee_delay = AO_CONFIG_DEFAULT_APOGEE_DELAY;
142 /* Fixups for minor version 2 */
144 ao_config.accel_plus_g = 0;
145 ao_config.accel_minus_g = 0;
147 /* Fixups for minor version 3 */
150 ao_config.radio_cal = ao_radio_cal;
152 /* Fixups for minor version 4 */
155 ao_config.flight_log_max = AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX;
157 /* Fixupes for minor version 5 */
159 ao_config.ignite_mode = AO_CONFIG_DEFAULT_IGNITE_MODE;
161 ao_config.pad_orientation = AO_CONFIG_DEFAULT_PAD_ORIENTATION;
163 ao_config.radio_enable = AO_RADIO_ENABLE_CORE;
165 ao_xmemset(&ao_config.aes_key, '\0', AO_AES_LEN);
167 ao_config.frequency = 434550 + ao_config._legacy_radio_channel * 100;
169 ao_config.apogee_lockout = 0;
172 memset(&ao_config.pyro, '\0', sizeof (ao_config.pyro));
175 ao_config.aprs_interval = AO_CONFIG_DEFAULT_APRS_INTERVAL;
178 ao_config.radio_power = AO_CONFIG_DEFAULT_RADIO_POWER;
182 ao_config.radio_amp = AO_CONFIG_DEFAULT_RADIO_AMP;
186 ao_config.accel_zero_along = 0;
187 ao_config.accel_zero_across = 0;
188 ao_config.accel_zero_through = 0;
190 /* Reset the main accel offsets to force
193 ao_config.accel_plus_g = 0;
194 ao_config.accel_minus_g = 0;
199 ao_config.mid_beep = AO_BEEP_MID_DEFAULT;
203 ao_config.tracker_motion = AO_TRACKER_MOTION_DEFAULT;
204 ao_config.tracker_interval = AO_TRACKER_INTERVAL_DEFAULT;
209 ao_config.pyro_time = AO_CONFIG_DEFAULT_PYRO_TIME;
213 ao_config.aprs_ssid = AO_CONFIG_DEFAULT_APRS_SSID;
217 ao_config.radio_rate = AO_CONFIG_DEFAULT_RADIO_RATE;
219 #if HAS_RADIO_FORWARD
221 ao_config.send_frequency = 434550;
223 ao_config.minor = AO_CONFIG_MINOR;
229 ao_config.frequency = 434550;
230 ao_config.radio_cal = ao_radio_cal;
231 ao_xmemcpy(&ao_config.callsign, CODE_TO_XDATA(AO_CONFIG_DEFAULT_CALLSIGN),
232 sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
235 ao_config_set_radio();
237 ao_config_loaded = 1;
241 _ao_config_edit_start(void)
243 ao_mutex_get(&ao_config_mutex);
248 _ao_config_edit_finish(void)
251 ao_mutex_put(&ao_config_mutex);
257 _ao_config_edit_start();
258 ao_mutex_put(&ao_config_mutex);
262 ao_config_callsign_show(void)
264 printf ("Callsign: \"%s\"\n", ao_config.callsign);
268 ao_config_callsign_set(void) __reentrant
271 static __xdata char callsign[AO_MAX_CALLSIGN + 1];
273 ao_xmemset(callsign, '\0', sizeof callsign);
276 while (ao_cmd_lex_c != '\n') {
277 if (c < AO_MAX_CALLSIGN)
278 callsign[c++] = ao_cmd_lex_c;
280 ao_cmd_status = ao_cmd_lex_error;
283 if (ao_cmd_status != ao_cmd_success)
285 _ao_config_edit_start();
286 ao_xmemcpy(&ao_config.callsign, &callsign,
287 AO_MAX_CALLSIGN + 1);
288 _ao_config_edit_finish();
294 ao_config_frequency_show(void) __reentrant
296 printf("Frequency: %ld\n",
297 ao_config.frequency);
301 ao_config_frequency_set(void) __reentrant
304 if (ao_cmd_status != ao_cmd_success)
306 _ao_config_edit_start();
307 ao_config.frequency = ao_cmd_lex_u32;
308 ao_config_set_radio();
309 _ao_config_edit_finish();
311 ao_radio_recv_abort();
317 #if HAS_RADIO_FORWARD
319 ao_config_send_frequency_show(void) __reentrant
321 printf("Send frequency: %ld\n",
322 ao_config.send_frequency);
326 ao_config_send_frequency_set(void) __reentrant
329 if (ao_cmd_status != ao_cmd_success)
331 _ao_config_edit_start();
332 ao_config.send_frequency = ao_cmd_lex_u32;
333 ao_config_set_radio();
334 _ao_config_edit_finish();
336 ao_radio_recv_abort();
345 ao_config_main_deploy_show(void) __reentrant
347 printf("Main deploy: %d meters\n",
348 ao_config.main_deploy);
352 ao_config_main_deploy_set(void) __reentrant
355 if (ao_cmd_status != ao_cmd_success)
357 _ao_config_edit_start();
358 ao_config.main_deploy = ao_cmd_lex_i;
359 _ao_config_edit_finish();
364 ao_config_accel_calibrate_show(void) __reentrant
366 printf("Accel cal +1g: %d -1g: %d\n",
367 ao_config.accel_plus_g, ao_config.accel_minus_g);
369 printf ("IMU cal along %d across %d through %d\n",
370 ao_config.accel_zero_along,
371 ao_config.accel_zero_across,
372 ao_config.accel_zero_through);
376 #define ACCEL_CALIBRATE_SAMPLES 1024
377 #define ACCEL_CALIBRATE_SHIFT 10
380 static int16_t accel_cal_along;
381 static int16_t accel_cal_across;
382 static int16_t accel_cal_through;
386 ao_config_accel_calibrate_auto(char *orientation) __reentrant
390 uint8_t cal_data_ring;
391 int16_t min = 32767, max = -32768;
393 int32_t accel_along_total = 0;
394 int32_t accel_across_total = 0;
395 int32_t accel_through_total = 0;
398 printf("Orient antenna %s and press a key...", orientation);
401 puts("\r\n"); flush();
402 puts("Calibrating..."); flush();
403 i = ACCEL_CALIBRATE_SAMPLES;
405 cal_data_ring = ao_sample_data;
407 ao_sleep(DATA_TO_XDATA(&ao_sample_data));
408 while (i && cal_data_ring != ao_sample_data) {
409 int16_t v = ao_data_accel(&ao_data_ring[cal_data_ring]);
410 accel_total += (int32_t) v;
411 if (v < min) min = v;
412 if (v > max) max = v;
414 accel_along_total += (int32_t) ao_data_along(&ao_data_ring[cal_data_ring]);
415 accel_across_total += (int32_t) ao_data_across(&ao_data_ring[cal_data_ring]);
416 accel_through_total += (int32_t) ao_data_through(&ao_data_ring[cal_data_ring]);
418 cal_data_ring = ao_data_ring_next(cal_data_ring);
423 accel_cal_along = accel_along_total >> ACCEL_CALIBRATE_SHIFT;
424 accel_cal_across = accel_across_total >> ACCEL_CALIBRATE_SHIFT;
425 accel_cal_through = accel_through_total >> ACCEL_CALIBRATE_SHIFT;
427 printf ("total %d min %d max %d\n", accel_total, min, max);
428 return accel_total >> ACCEL_CALIBRATE_SHIFT;
432 ao_config_accel_calibrate_set(void) __reentrant
436 int16_t accel_along_up = 0, accel_along_down = 0;
437 int16_t accel_across_up = 0, accel_across_down = 0;
438 int16_t accel_through_up = 0, accel_through_down = 0;
442 if (ao_cmd_status != ao_cmd_success)
444 if (ao_cmd_lex_i == 0) {
445 up = ao_config_accel_calibrate_auto("up");
447 accel_along_up = accel_cal_along;
448 accel_across_up = accel_cal_across;
449 accel_through_up = accel_cal_through;
451 down = ao_config_accel_calibrate_auto("down");
453 accel_along_down = accel_cal_along;
454 accel_across_down = accel_cal_across;
455 accel_through_down = accel_cal_through;
460 if (ao_cmd_status != ao_cmd_success)
465 printf("Invalid accel: up (%d) down (%d)\n",
469 _ao_config_edit_start();
470 ao_config.accel_plus_g = up;
471 ao_config.accel_minus_g = down;
473 if (ao_cmd_lex_i == 0) {
474 ao_config.accel_zero_along = (accel_along_up + accel_along_down) / 2;
475 ao_config.accel_zero_across = (accel_across_up + accel_across_down) / 2;
476 ao_config.accel_zero_through = (accel_through_up + accel_through_down) / 2;
479 _ao_config_edit_finish();
481 #endif /* HAS_ACCEL */
484 ao_config_apogee_delay_show(void) __reentrant
486 printf("Apogee delay: %d seconds\n",
487 ao_config.apogee_delay);
491 ao_config_apogee_delay_set(void) __reentrant
494 if (ao_cmd_status != ao_cmd_success)
496 _ao_config_edit_start();
497 ao_config.apogee_delay = ao_cmd_lex_i;
498 _ao_config_edit_finish();
502 ao_config_apogee_lockout_show(void) __reentrant
504 printf ("Apogee lockout: %d seconds\n",
505 ao_config.apogee_lockout);
509 ao_config_apogee_lockout_set(void) __reentrant
512 if (ao_cmd_status != ao_cmd_success)
514 _ao_config_edit_start();
515 ao_config.apogee_lockout = ao_cmd_lex_i;
516 _ao_config_edit_finish();
519 #endif /* HAS_FLIGHT */
523 ao_config_radio_cal_show(void) __reentrant
525 printf("Radio cal: %ld\n", ao_config.radio_cal);
529 ao_config_radio_cal_set(void) __reentrant
532 if (ao_cmd_status != ao_cmd_success)
534 _ao_config_edit_start();
535 ao_config.radio_cal = ao_cmd_lex_u32;
536 ao_config_set_radio();
537 _ao_config_edit_finish();
543 #ifndef HAS_TELEMETRY
544 #error Please define HAS_TELEMETRY
548 ao_config_radio_rate_show(void) __reentrant
550 printf("Telemetry rate: %d\n", ao_config.radio_rate);
554 ao_config_radio_rate_set(void) __reentrant
557 if (ao_cmd_status != ao_cmd_success)
559 if (AO_RADIO_RATE_MAX < ao_cmd_lex_i) {
560 ao_cmd_status = ao_cmd_lex_error;
563 _ao_config_edit_start();
564 ao_config.radio_rate = ao_cmd_lex_i;
565 _ao_config_edit_finish();
567 ao_telemetry_reset_interval();
570 ao_radio_recv_abort();
578 ao_config_log_show(void) __reentrant
580 printf("Max flight log: %d kB\n", (int16_t) (ao_config.flight_log_max >> 10));
581 #if FLIGHT_LOG_APPEND
582 printf("Log fixed: 1\n");
586 #if FLIGHT_LOG_APPEND
588 ao_config_log_fix_append(void)
590 _ao_config_edit_start();
591 ao_config.flight_log_max = ao_storage_log_max;
592 _ao_config_edit_finish();
593 ao_mutex_get(&ao_config_mutex);
596 ao_mutex_put(&ao_config_mutex);
601 ao_config_log_set(void) __reentrant
603 #if FLIGHT_LOG_APPEND
604 printf("Flight log fixed size %d kB\n", ao_storage_log_max >> 10);
606 uint16_t block = (uint16_t) (ao_storage_block >> 10);
607 uint16_t log_max = (uint16_t) (ao_storage_log_max >> 10);
610 if (ao_cmd_status != ao_cmd_success)
612 if (ao_log_present())
613 printf("Storage must be empty before changing log size\n");
614 else if (block > 1024 && (ao_cmd_lex_i & (block - 1)))
615 printf("Flight log size must be multiple of %d kB\n", block);
616 else if (ao_cmd_lex_i > log_max)
617 printf("Flight log max %d kB\n", log_max);
619 _ao_config_edit_start();
620 ao_config.flight_log_max = (uint32_t) ao_cmd_lex_i << 10;
621 _ao_config_edit_finish();
629 ao_config_ignite_mode_show(void) __reentrant
631 printf("Ignite mode: %d\n", ao_config.ignite_mode);
635 ao_config_ignite_mode_set(void) __reentrant
638 if (ao_cmd_status != ao_cmd_success)
640 _ao_config_edit_start();
641 ao_config.ignite_mode = ao_cmd_lex_i;
642 _ao_config_edit_finish();
648 ao_config_pad_orientation_show(void) __reentrant
650 printf("Pad orientation: %d\n", ao_config.pad_orientation);
653 #ifndef AO_ACCEL_INVERT
654 #define AO_ACCEL_INVERT 0x7fff
658 ao_config_pad_orientation_set(void) __reentrant
661 if (ao_cmd_status != ao_cmd_success)
663 _ao_config_edit_start();
665 if (ao_config.pad_orientation != ao_cmd_lex_i) {
667 t = ao_config.accel_plus_g;
668 ao_config.accel_plus_g = AO_ACCEL_INVERT - ao_config.accel_minus_g;
669 ao_config.accel_minus_g = AO_ACCEL_INVERT - t;
671 ao_config.pad_orientation = ao_cmd_lex_i;
672 _ao_config_edit_finish();
678 ao_config_radio_enable_show(void) __reentrant
680 printf("Radio enable: %d\n", ao_config.radio_enable);
684 ao_config_radio_enable_set(void) __reentrant
687 if (ao_cmd_status != ao_cmd_success)
689 _ao_config_edit_start();
690 ao_config.radio_enable = ao_cmd_lex_i;
691 _ao_config_edit_finish();
692 #if HAS_TELEMETRY && HAS_RADIO_RATE
693 ao_telemetry_reset_interval();
696 #endif /* HAS_RADIO */
700 __xdata uint8_t ao_config_aes_seq = 1;
703 ao_config_key_show(void) __reentrant
707 for (i = 0; i < AO_AES_LEN; i++)
708 printf ("%02x", ao_config.aes_key[i]);
713 ao_config_key_set(void) __reentrant
717 _ao_config_edit_start();
718 for (i = 0; i < AO_AES_LEN; i++) {
720 if (ao_cmd_status != ao_cmd_success)
722 ao_config.aes_key[i] = ao_cmd_lex_i;
725 _ao_config_edit_finish();
732 ao_config_aprs_show(void)
734 printf ("APRS interval: %d\n", ao_config.aprs_interval);
738 ao_config_aprs_set(void)
741 if (ao_cmd_status != ao_cmd_success)
743 _ao_config_edit_start();
744 ao_config.aprs_interval = ao_cmd_lex_i;
745 _ao_config_edit_finish();
746 ao_telemetry_reset_interval();
749 #endif /* HAS_APRS */
754 ao_config_radio_amp_show(void)
756 printf ("Radio amp setting: %d\n", ao_config.radio_amp);
760 ao_config_radio_amp_set(void)
763 if (ao_cmd_status != ao_cmd_success)
765 _ao_config_edit_start();
766 ao_config.radio_amp = ao_cmd_lex_i;
767 _ao_config_edit_finish();
775 ao_config_radio_power_show(void)
777 printf ("Radio power setting: %d\n", ao_config.radio_power);
781 ao_config_radio_power_set(void)
784 if (ao_cmd_status != ao_cmd_success)
786 _ao_config_edit_start();
787 ao_config.radio_power = ao_cmd_lex_i;
788 _ao_config_edit_finish();
795 ao_config_beep_show(void)
797 printf ("Beeper setting: %d\n", ao_config.mid_beep);
801 ao_config_beep_set(void)
804 if (ao_cmd_status != ao_cmd_success)
806 _ao_config_edit_start();
807 ao_config.mid_beep = ao_cmd_lex_i;
808 _ao_config_edit_finish();
814 ao_config_tracker_show(void)
816 printf ("Tracker setting: %d %d\n",
817 ao_config.tracker_motion,
818 ao_config.tracker_interval);
822 ao_config_tracker_set(void)
826 if (ao_cmd_status != ao_cmd_success)
830 if (ao_cmd_status != ao_cmd_success)
833 _ao_config_edit_start();
834 ao_config.tracker_motion = m;
835 ao_config.tracker_interval = i;
836 _ao_config_edit_finish();
838 ao_telemetry_reset_interval();
841 #endif /* HAS_TRACKER */
845 ao_config_pyro_time_show(void)
847 printf ("Pyro time: %d\n", ao_config.pyro_time);
851 ao_config_pyro_time_set(void)
854 if (ao_cmd_status != ao_cmd_success)
856 _ao_config_edit_start();
857 ao_config.pyro_time = ao_cmd_lex_i;
858 _ao_config_edit_finish();
864 ao_config_aprs_ssid_show(void)
866 printf ("APRS SSID: %d\n",
867 ao_config.aprs_ssid);
871 ao_config_aprs_ssid_set(void)
874 if (ao_cmd_status != ao_cmd_success)
876 if (15 < ao_cmd_lex_i) {
877 ao_cmd_status = ao_cmd_lex_error;
880 _ao_config_edit_start();
881 ao_config.aprs_ssid = ao_cmd_lex_i;
882 _ao_config_edit_finish();
884 #endif /* HAS_APRS */
886 struct ao_config_var {
888 void (*set)(void) __reentrant;
889 void (*show)(void) __reentrant;
893 ao_config_help(void) __reentrant;
896 ao_config_show(void) __reentrant;
900 ao_config_save(void) __reentrant;
903 __code struct ao_config_var ao_config_vars[] = {
905 { "m <meters>\0Main deploy (m)",
906 ao_config_main_deploy_set, ao_config_main_deploy_show, },
907 { "d <delay>\0Apogee delay (s)",
908 ao_config_apogee_delay_set, ao_config_apogee_delay_show },
909 { "L <seconds>\0Apogee detect lockout (s)",
910 ao_config_apogee_lockout_set, ao_config_apogee_lockout_show, },
911 #endif /* HAS_FLIGHT */
913 { "F <freq>\0Frequency (kHz)",
914 ao_config_frequency_set, ao_config_frequency_show },
915 #if HAS_RADIO_FORWARD
916 { "R <freq>\0Repeater output frequency (kHz)",
917 ao_config_send_frequency_set, ao_config_send_frequency_show },
919 { "c <call>\0Callsign (8 char max)",
920 ao_config_callsign_set, ao_config_callsign_show },
921 { "e <0 disable, 1 enable>\0Enable telemetry and RDF",
922 ao_config_radio_enable_set, ao_config_radio_enable_show },
923 { "f <cal>\0Radio calib (cal = rf/(xtal/2^16))",
924 ao_config_radio_cal_set, ao_config_radio_cal_show },
926 { "T <rate>\0Telemetry rate (0=38.4, 1=9.6, 2=2.4)",
927 ao_config_radio_rate_set, ao_config_radio_rate_show },
930 { "p <setting>\0Radio power setting (0-255)",
931 ao_config_radio_power_set, ao_config_radio_power_show },
934 { "d <setting>\0Radio amplifier setting (0-3)",
935 ao_config_radio_amp_set, ao_config_radio_amp_show },
937 #endif /* HAS_RADIO */
939 { "a <+g> <-g>\0Accel calib (0 for auto)",
940 ao_config_accel_calibrate_set,ao_config_accel_calibrate_show },
941 { "o <0 antenna up, 1 antenna down>\0Pad orientation",
942 ao_config_pad_orientation_set,ao_config_pad_orientation_show },
943 #endif /* HAS_ACCEL */
945 { "l <size>\0Flight log size (kB)",
946 ao_config_log_set, ao_config_log_show },
949 { "i <0 dual, 1 apogee, 2 main>\0Igniter mode",
950 ao_config_ignite_mode_set, ao_config_ignite_mode_show },
953 { "k <32 hex digits>\0AES encryption key",
954 ao_config_key_set, ao_config_key_show },
957 { "P <n,?>\0Pyro channels",
958 ao_pyro_set, ao_pyro_show },
959 { "I <ticks>\0Pyro firing time",
960 ao_config_pyro_time_set, ao_config_pyro_time_show },
963 { "A <secs>\0APRS packet interval (0 disable)",
964 ao_config_aprs_set, ao_config_aprs_show },
967 { "b <val>\0Beeper tone (freq = 1/2 (24e6/32) / beep",
968 ao_config_beep_set, ao_config_beep_show },
971 { "t <motion> <interval>\0Tracker configuration",
972 ao_config_tracker_set, ao_config_tracker_show },
975 { "S <ssid>\0Set APRS SSID (0-15)",
976 ao_config_aprs_ssid_set, ao_config_aprs_ssid_show },
981 { "w\0Write to eeprom",
998 for (cmd = 0; ao_config_vars[cmd].str != NULL; cmd++)
999 if (ao_config_vars[cmd].str[0] == c) {
1000 (*ao_config_vars[cmd].set)();
1003 ao_cmd_status = ao_cmd_syntax_error;
1007 ao_config_help(void) __reentrant
1010 for (cmd = 0; ao_config_vars[cmd].str != NULL; cmd++)
1011 printf("%-20s %s\n",
1012 ao_config_vars[cmd].str,
1013 ao_config_vars[cmd].str+1+
1014 strlen(ao_config_vars[cmd].str));
1018 ao_config_show(void) __reentrant
1022 printf("Config version: %d.%d\n",
1023 ao_config.major, ao_config.minor);
1024 for (cmd = 0; ao_config_vars[cmd].str != NULL; cmd++)
1025 if (ao_config_vars[cmd].show)
1026 (*ao_config_vars[cmd].show)();
1034 ao_config_save(void) __reentrant
1037 ao_mutex_get(&ao_config_mutex);
1038 if (ao_config_dirty) {
1040 ao_config_dirty = 0;
1043 ao_mutex_put(&ao_config_mutex);
1047 puts("Nothing to save");
1051 __code struct ao_cmds ao_config_cmds[] = {
1052 { ao_config_set, "c <var> <value>\0Set config (? for help, s to show)" },
1057 ao_config_init(void)
1059 ao_cmd_register(&ao_config_cmds[0]);