Пример #1
0
void DW1000RangingClass::transmitRange(DW1000Device *myDistantDevice) {
    //transmit range need to accept broadcast for multiple anchor
    transmitInit();
    
    
    if(myDistantDevice==NULL)
    {
        //we need to set our timerDelay:
        _timerDelay=DEFAULT_TIMER_DELAY+(int)(_networkDevicesNumber*3*DEFAULT_REPLY_DELAY_TIME/1000);
        
        byte shortBroadcast[2]={0xFF, 0xFF};
        _globalMac.generateShortMACFrame(data, _currentShortAddress, shortBroadcast);
        data[SHORT_MAC_LEN] = RANGE;
        //we enter the number of devices
        data[SHORT_MAC_LEN+1]=_networkDevicesNumber;
        
        // delay sending the message and remember expected future sent timestamp
        DW1000Time deltaTime = DW1000Time(DEFAULT_REPLY_DELAY_TIME, DW_MICROSECONDS);
        DW1000Time timeRangeSent = DW1000.setDelay(deltaTime);
        
        for(short i=0; i<_networkDevicesNumber; i++)
        {
            //we write the short address of our device:
            memcpy(data+SHORT_MAC_LEN+2+17*i, _networkDevices[i].getByteShortAddress(), 2);
            
            
            //we get the device which correspond to the message which was sent (need to be filtered by MAC address)
            _networkDevices[i].timeRangeSent = timeRangeSent;
            _networkDevices[i].timePollSent.getTimestamp(data+SHORT_MAC_LEN+4+17*i);
            _networkDevices[i].timePollAckReceived.getTimestamp(data+SHORT_MAC_LEN+9+17*i);
            _networkDevices[i].timeRangeSent.getTimestamp(data+SHORT_MAC_LEN+14+17*i);
            
        }
        
        copyShortAddress(_lastSentToShortAddress, shortBroadcast);
        
    }
    else{
        _globalMac.generateShortMACFrame(data, _currentShortAddress, myDistantDevice->getByteShortAddress());
        data[SHORT_MAC_LEN] = RANGE;
        // delay sending the message and remember expected future sent timestamp
        DW1000Time deltaTime = DW1000Time(_replyDelayTimeUS, DW_MICROSECONDS);
        //we get the device which correspond to the message which was sent (need to be filtered by MAC address)
        myDistantDevice->timeRangeSent = DW1000.setDelay(deltaTime);
        myDistantDevice->timePollSent.getTimestamp(data+1+SHORT_MAC_LEN);
        myDistantDevice->timePollAckReceived.getTimestamp(data+6+SHORT_MAC_LEN);
        myDistantDevice->timeRangeSent.getTimestamp(data+11+SHORT_MAC_LEN);
        copyShortAddress(_lastSentToShortAddress,myDistantDevice->getByteShortAddress());
    }
    
    
    transmit(data);
}
Пример #2
0
void DW1000RangingClass::transmitPollAck(DW1000Device *myDistantDevice) {
    transmitInit();
    _globalMac.generateShortMACFrame(data, _currentShortAddress, myDistantDevice->getByteShortAddress());
    data[SHORT_MAC_LEN] = POLL_ACK;
    // delay the same amount as ranging tag
    DW1000Time deltaTime = DW1000Time(_replyDelayTimeUS, DW_MICROSECONDS);
    copyShortAddress(_lastSentToShortAddress,myDistantDevice->getByteShortAddress());
    transmit(data, deltaTime);
}
Пример #3
0
void DW1000RangingClass::transmitPollAck() {
    DW1000.newTransmit();
    DW1000.setDefaults();
    data[0] = POLL_ACK;
    // delay the same amount as ranging tag
    DW1000Time deltaTime = DW1000Time(_replyDelayTimeUS, MICROSECONDS);
    DW1000.setDelay(deltaTime);
    DW1000.setData(data, LEN_DATA);
    //DW1000.setDest();
    DW1000.startTransmit();
}
Пример #4
0
void DW1000RangingClass::transmitRangeReport(DW1000Device* myDistantDevice) {
	transmitInit();
	_globalMac.generateShortMACFrame(data, _currentShortAddress, myDistantDevice->getByteShortAddress());
	data[SHORT_MAC_LEN] = RANGE_REPORT;
	// write final ranging result
	float curRange   = myDistantDevice->getRange();
	float curRXPower = myDistantDevice->getRXPower();
	//We add the Range and then the RXPower
	memcpy(data+1+SHORT_MAC_LEN, &curRange, 4);
	memcpy(data+5+SHORT_MAC_LEN, &curRXPower, 4);
	copyShortAddress(_lastSentToShortAddress, myDistantDevice->getByteShortAddress());
	transmit(data, DW1000Time(_replyDelayTimeUS, DW_MICROSECONDS));
}
Пример #5
0
void DW1000RangingClass::transmitRange(DW1000Device *myDistantDevice) {
    transmitInit();
    _globalMac.generateShortMACFrame(data, _currentShortAddress, myDistantDevice->getByteShortAddress());
    data[SHORT_MAC_LEN] = RANGE;
    // delay sending the message and remember expected future sent timestamp
    DW1000Time deltaTime = DW1000Time(_replyDelayTimeUS, DW_MICROSECONDS);
    //we get the device which correspond to the message which was sent (need to be filtered by MAC address)
    myDistantDevice->timeRangeSent = DW1000.setDelay(deltaTime);
    myDistantDevice->timePollSent.getTimestamp(data+1+SHORT_MAC_LEN);
    myDistantDevice->timePollAckReceived.getTimestamp(data+6+SHORT_MAC_LEN);
    myDistantDevice->timeRangeSent.getTimestamp(data+11+SHORT_MAC_LEN);
    copyShortAddress(_lastSentToShortAddress,myDistantDevice->getByteShortAddress());
    transmit(data);
    //Serial.print("Expect RANGE to be sent @ "); Serial.println(timeRangeSent.getAsFloat());
}
Пример #6
0
void DW1000RangingClass::transmitRange(DW1000Device *myDistantDevice) {
    DW1000.newTransmit();
    DW1000.setDefaults();
    data[0] = RANGE;
    // delay sending the message and remember expected future sent timestamp
    DW1000Time deltaTime = DW1000Time(_replyDelayTimeUS, MICROSECONDS);
    //we get the device which correspond to the message which was sent (need to be filtered by MAC address)
    (*myDistantDevice).timeRangeSent = DW1000.setDelay(deltaTime);
    (*myDistantDevice).timePollSent.getTimestamp(data+1);
    (*myDistantDevice).timePollAckReceived.getTimestamp(data+6);
    (*myDistantDevice).timeRangeSent.getTimestamp(data+11);
    DW1000.setData(data, LEN_DATA);
    DW1000.startTransmit();
    //Serial.print("Expect RANGE to be sent @ "); Serial.println(timeRangeSent.getAsFloat());
}
Пример #7
0
DW1000Time DW1000Time::operator/(const DW1000Time &factor) const {
	return DW1000Time(*this) /= factor;
}
Пример #8
0
DW1000Time DW1000Time::operator/(float factor) const {
	return DW1000Time(*this) /= factor;
}
Пример #9
0
DW1000Time DW1000Time::operator-(const DW1000Time &sub) const {
	return DW1000Time(*this) -= sub;
}
Пример #10
0
DW1000Time DW1000Time::operator+(const DW1000Time &add) const {
    return DW1000Time(*this) += add;
}