コード例 #1
0
void DW1000RangingClass::transmitPoll(DW1000Device *myDistantDevice) {
    transmitInit();
    //we generate the mac frame for a Poll message
    _globalMac.generateShortMACFrame(data, _currentShortAddress, myDistantDevice->getByteShortAddress());
    data[SHORT_MAC_LEN] = POLL;
    copyShortAddress(_lastSentToShortAddress,myDistantDevice->getByteShortAddress());
    transmit(data);
}
コード例 #2
0
void DW1000RangingClass::transmitRangeFailed(DW1000Device *myDistantDevice) {
    transmitInit();
    _globalMac.generateShortMACFrame(data, _currentShortAddress, myDistantDevice->getByteShortAddress());
    data[SHORT_MAC_LEN] = RANGE_FAILED;
    
    copyShortAddress(_lastSentToShortAddress,myDistantDevice->getByteShortAddress());
    transmit(data);
}
コード例 #3
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);
}
コード例 #4
0
void DW1000RangingClass::transmitRangingInit(DW1000Device *myDistantDevice){
    transmitInit();
    //we generate the mac frame for a ranging init message
    _globalMac.generateLongMACFrame(data, _currentShortAddress, myDistantDevice->getByteAddress());
    //we define the function code
    data[LONG_MAC_LEN]=RANGING_INIT;
    
    copyShortAddress(_lastSentToShortAddress,myDistantDevice->getByteShortAddress());
    
    transmit(data);
}
コード例 #5
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);
}
コード例 #6
0
void DW1000RangingClass::transmitPoll(DW1000Device *myDistantDevice) {

    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] = POLL;
        //we enter the number of devices
        data[SHORT_MAC_LEN+1]=_networkDevicesNumber;
        
        for(short i=0; i<_networkDevicesNumber; i++)
        {
            //each devices have a different reply delay time.
            _networkDevices[i].setReplyTime((2*i+1)*DEFAULT_REPLY_DELAY_TIME);
            //we write the short address of our device:
            memcpy(data+SHORT_MAC_LEN+2+4*i, _networkDevices[i].getByteShortAddress(), 2);
            
            //we add the replyTime
            unsigned int replyTime=_networkDevices[i].getReplyTime();
            memcpy(data+SHORT_MAC_LEN+2+2+4*i, &replyTime, 2);
            
        }
        
        copyShortAddress(_lastSentToShortAddress,shortBroadcast);
        
    }
    else{
        //we redefine our default_timer_delay for just 1 device;
        _timerDelay=DEFAULT_TIMER_DELAY;
        
        _globalMac.generateShortMACFrame(data, _currentShortAddress, myDistantDevice->getByteShortAddress());
        
        data[SHORT_MAC_LEN] = POLL;
        data[SHORT_MAC_LEN+1]=1;
        unsigned int replyTime=myDistantDevice->getReplyTime();
        memcpy(data+SHORT_MAC_LEN+2, &replyTime, sizeof(int));
        
        copyShortAddress(_lastSentToShortAddress,myDistantDevice->getByteShortAddress());
    }
    
    
    
    
    
    transmit(data);
}
コード例 #7
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);
}
コード例 #8
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());
}
コード例 #9
0
void DW1000RangingClass::transmitBlink(){
    transmitInit();
    _globalMac.generateBlinkFrame(data, _currentAddress, _currentShortAddress);
    transmit(data);
}