]> git.droids-corp.org - protos/xbee-avr.git/commitdiff
fix range_cb command
authorOlivier Matz <zer0@droids-corp.org>
Sat, 8 Mar 2014 20:16:26 +0000 (21:16 +0100)
committerOlivier Matz <zer0@droids-corp.org>
Sun, 9 Mar 2014 21:13:09 +0000 (22:13 +0100)
commands.c

index 2c663c1f7b0564aaf43a18691f5d73b4381c915b..b64dfb1cf60580ac04715b1b7b46e7ff331bc363 100644 (file)
@@ -67,7 +67,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;
@@ -92,12 +92,9 @@ static void monitor_cb(struct callout_mgr *cm,
 static void range_cb(struct callout_mgr *cm,
                     struct callout *clt, void *dummy)
 {
-       (void)cm;
-       (void)clt;
-       (void)dummy;
-#if 0
+       struct rc_proto_power_probe power_probe;
+       struct xbee_msg msg;
        uint8_t i, mask;
-       struct rc_proto_range rangepkt;
 
        (void)clt;
        (void)dummy;
@@ -112,20 +109,26 @@ static void range_cb(struct callout_mgr *cm,
        }
        range_power = ((range_power + i) & 0x7);
 
-       xbeeapp_send_atcmd("PL", &range_power, sizeof(range_power), 0, NULL, NULL);
+       xbeeapp_send_atcmd("PL", &range_power, sizeof(range_power), NULL, NULL);
+
+       power_probe.type = RC_PROTO_POWER_PROBE;
+       power_probe.power_level = range_power;
 
-       rangepkt.type = RC_PROTO_TYPE_RANGE;
-       rangepkt.power_level = range_power;
+       msg.iovlen = 1;
+       msg.iov[0].buf = &power_probe;
+       msg.iov[0].len = sizeof(power_probe);
 
-       xbeeapp_send_msg(range_dstaddr, &rangepkt, sizeof(rangepkt), 0);
+       xbeeapp_send_msg(range_dstaddr, &msg, NULL, NULL);
 
        if (range_cur_count == 0) {
                range_running = 0;
                callout_stop(cm, clt);
+               return;
        }
 
        callout_reschedule(cm, clt, range_period_ms);
-#endif
+}
+
 /* callback invoked when a xbee_send is done */
 static int8_t send_msg_cb(int8_t retcode, void *frame, unsigned len,
        void *arg)