Tobi's ubw test branch
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
Diff: MMRanging/MMRanging.cpp
- Revision:
- 35:95d838d33bf5
- Parent:
- 34:f56962030c5c
- Child:
- 36:883de6f9a73b
diff -r f56962030c5c -r 95d838d33bf5 MMRanging/MMRanging.cpp --- a/MMRanging/MMRanging.cpp Sat Dec 27 14:37:12 2014 +0000 +++ b/MMRanging/MMRanging.cpp Tue Feb 17 10:58:58 2015 +0000 @@ -1,15 +1,8 @@ #include "MMRanging.h" MMRanging::MMRanging(DW1000& DW) : dw(DW) { - MMRanging::dw = dw; - - ranging_i = 0; - - message[0] = '\0'; - messageRX[0] = '\0'; event_i = 0; counter = 0; - dw.setCallbacks(this, &MMRanging::callbackRX, &MMRanging::callbackTX); dw.startRX(); } @@ -24,23 +17,16 @@ switch (RX.type) { case 1: rangingtimingsReceiver[Index][0] = dw.getRXTimestamp(); - TX.type = 2; - TX.sequence_number = RX.sequence_number; - TX.time_difference_receiver = 0; - dw.sendFrame((uint8_t*)&TX, sizeof(TX)); + sendRangingframe(2, RX.sequence_number, 0); break; case 2: rangingtimingsSender[Index][1] = dw.getRXTimestamp(); break; case 3: - TX.type = 4; - TX.time_difference_receiver = rangingtimingsReceiver[Index][1] - rangingtimingsReceiver[Index][0]; - dw.sendFrame((uint8_t*)&TX, sizeof(TX)); + sendRangingframe(4, TX.sequence_number, rangingtimingsReceiver[Index][1] - rangingtimingsReceiver[Index][0]); // TODO: sequence number??? break; case 4: - //tofs[Index] = RX.time_difference_receiver; - tofs[Index] = (rangingtimingsSender[Index][1] - rangingtimingsSender[Index][0] - RX.time_difference_receiver);// - 65536; - //tofs[RX->sequence_number] = (rangingtimingsSender[RX->sequence_number][1] - rangingtimingsSender[RX->sequence_number][0] - RX->time_difference_receiver) >> 1; + tofs = (rangingtimingsSender[Index][1] - rangingtimingsSender[Index][0] - RX.time_difference_receiver);// - 65536; break; default : break; } @@ -83,21 +69,15 @@ } void MMRanging::requestRanging() { - TX.type = 1; - TX.sequence_number = counter; - TX.time_difference_receiver = 0; - dw.sendFrame((uint8_t*)&TX, sizeof(TX)); + sendRangingframe(1, counter, 0); } void MMRanging::requestTime() { - TX.type = 3; - TX.sequence_number = counter; - TX.time_difference_receiver = 0; - dw.sendFrame((uint8_t*)&TX, sizeof(TX)); + sendRangingframe(3, counter, 0); counter++; } -void MMRanging::sendRangingframe(uint8_t type, uint8_t sequence_number, uint64_t time_difference_receiver, uint16_t dummy) { +void MMRanging::sendRangingframe(uint8_t type, uint8_t sequence_number, uint64_t time_difference_receiver) { TX.type = type; TX.sequence_number = sequence_number; TX.time_difference_receiver = time_difference_receiver;