Mercator: fix a off-by-one bug in cb_sendPacket()
This bug causes openmote-b to send one more packet than
txpk_totalnumpk.
This bug has no effect on IoT-LAB M3. Because its radio
driver (radio_txNow()) doesn't wait SFD and its CPU is fast,
radio_txNow() seems to be canceled by the following radio_rfOff() in
if-block.
@@ -533,15 +533,6 @@ void cb_sendPacket(opentimers_id_t id){
uint16_t pkctr;
uint8_t pkctr_offset = 10; // srcmac[8] + transctr[2]
- // send packet
- leds_error_on();
-
- radio_loadPacket(mercator_vars.rfbuftx, mercator_vars.txpk_len);
- radio_txEnable();
- radio_txNow();
-
- leds_error_off();
-
if (mercator_vars.txpk_numpk == mercator_vars.txpk_totalnumpk) {
opentimers_cancel(mercator_vars.sendTimerId);
@@ -566,6 +557,15 @@ void cb_sendPacket(opentimers_id_t id){
return;
}
+ // send packet
+ leds_error_on();
+
+ radio_loadPacket(mercator_vars.rfbuftx, mercator_vars.txpk_len);
+ radio_txEnable();
+ radio_txNow();
+
+ leds_error_off();
+
// update pkctr
mercator_vars.txpk_numpk++;
pkctr = htons(mercator_vars.txpk_numpk);
