add a command to dump xbee stats
[protos/xbee-avr.git] / commands.c
index eff413d..319e1fa 100644 (file)
 #include <parse_string.h>
 #include <parse_num.h>
 #include <uart.h>
-
-#include "xbee_atcmd.h"
-#include "xbee_neighbor.h"
-#include "xbee_stats.h"
-#include "xbee_proto.h"
-#include "xbee.h"
+#include <xbee.h>
 
 #include "callout.h"
 #include "parse_atcmd.h"
@@ -71,7 +66,7 @@ struct monitor_reg *monitor_current;
 
 static int range_period_ms = 1000;
 static int range_powermask = 0x1F;
-static uint8_t range_power = 0;
+//static uint8_t range_power = 0;
 static int range_running = 0;
 static uint64_t range_dstaddr = 0xFFFF; /* broadcast by default */
 static struct callout range_event;
@@ -97,6 +92,10 @@ static void monitor_cb(struct callout_manager *cm,
 static void range_cb(struct callout_manager *cm,
                     struct callout *clt, void *dummy)
 {
+       (void)cm;
+       (void)clt;
+       (void)dummy;
+#if 0
        uint8_t i, mask;
        struct rc_proto_range rangepkt;
 
@@ -128,6 +127,7 @@ static void range_cb(struct callout_manager *cm,
        callout_reset(cm, &range_event,
                      range_period_ms,
                      SINGLE, range_cb, NULL);
+#endif
 }
 
 /* this structure is filled when cmd_help is parsed successfully */
@@ -1553,6 +1553,37 @@ const parse_inst_t PROGMEM cmd_test_spi = {
 
 /**********************************************************/
 
+/* this structure is filled when cmd_dump_xbee_stats is parsed successfully */
+struct cmd_dump_xbee_stats_result {
+       fixed_string_t arg0;
+};
+
+static void cmd_dump_xbee_stats_parsed(void *parsed_result, void *data)
+{
+       (void)parsed_result;
+       (void)data;
+
+       xbee_dump_stats(xbee_dev);
+}
+
+const char PROGMEM str_dump_xbee_stats_arg0[] = "dump_xbee_stats";
+const parse_token_string_t PROGMEM cmd_dump_xbee_stats_arg0 =
+       TOKEN_STRING_INITIALIZER(struct cmd_dump_xbee_stats_result, arg0,
+                                str_dump_xbee_stats_arg0);
+
+const char PROGMEM help_dump_xbee_stats[] = "Test the spi";
+const parse_inst_t PROGMEM cmd_dump_xbee_stats = {
+       .f = cmd_dump_xbee_stats_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_dump_xbee_stats,
+       .tokens = {        /* token list, NULL terminated */
+               (PGM_P)&cmd_dump_xbee_stats_arg0,
+               NULL,
+       },
+};
+
+/**********************************************************/
+
 /* this structure is filled when cmd_test_eeprom_config is parsed successfully */
 struct cmd_test_eeprom_config_result {
        fixed_string_t arg0;
@@ -1798,6 +1829,7 @@ const parse_ctx_t PROGMEM main_ctx[] = {
        &cmd_servo_bypassppm,
        &cmd_servo_show,
        &cmd_test_spi,
+       &cmd_dump_xbee_stats,
        &cmd_test_eeprom_config,
        &cmd_eeprom_del,
        &cmd_eeprom_add,