Skip to content

Commit

Permalink
fixed reception issue with different EUIs
Browse files Browse the repository at this point in the history
  • Loading branch information
abiri committed Oct 16, 2018
1 parent 2f66d94 commit c52bad6
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
5 changes: 3 additions & 2 deletions software/module/firmware/app_standard_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void standard_configure (module_config_t* config) {
// Set EUI
dw1000_read_eui(_config.my_EUI);
// FIXME: Load actual EUI to FLASH
_config.my_EUI[0] = 0xF0;
_config.my_EUI[0] = APP_EUI_FIRST_BYTE;

// Now init based on role
_config.init_active = FALSE;
Expand Down Expand Up @@ -123,7 +123,7 @@ void standard_start () {
// Make sure the SPI speed is slow for this function
dw1000_spi_slow();

// Setup callbacks to this ANCHOR
// Setup general callbacks
dwt_setcallbacks(common_txcallback, common_rxcallback, common_rxcallback, common_rxcallback);

// Make sure the radio starts off
Expand All @@ -133,6 +133,7 @@ void standard_start () {
dwt_enableframefilter(DWT_FF_DATA_EN | DWT_FF_ACK_EN);

// Don't use these
dwt_setdblrxbuffmode(FALSE);
dwt_setrxtimeout(FALSE);

// Make SPI fast now that everything has been setup
Expand Down
19 changes: 11 additions & 8 deletions software/module/firmware/app_standard_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void standard_initiator_init (standard_init_scratchspace_struct *app_scratchspac

// Initialize important variables inside scratchspace
si_scratch->pp_tag_poll_pkt = (struct pp_tag_poll) {
{ // 802.15.4 HEADER
.header = { // 802.15.4 HEADER
{
0x41, // FCF[0]: data frame, panid compression
0xC8 // FCF[1]: ext source address, compressed destination
Expand All @@ -54,18 +54,21 @@ void standard_initiator_init (standard_init_scratchspace_struct *app_scratchspac
{ 0 } // Source (blank for now)
},
// PACKET BODY
MSG_TYPE_PP_NOSLOTS_TAG_POLL, // Message type
0, // Sub Sequence number
NUM_RANGING_BROADCASTS-1,
RANGING_LISTENING_WINDOW_US,
RANGING_LISTENING_SLOT_US,
{ { 0 } }
.message_type = MSG_TYPE_PP_NOSLOTS_TAG_POLL, // Message type
.subsequence = 0, // Sub Sequence number
.reply_after_subsequence = NUM_RANGING_BROADCASTS-1,
.anchor_reply_window_in_us = RANGING_LISTENING_WINDOW_US,
.anchor_reply_slot_time_in_us = RANGING_LISTENING_SLOT_US,
.footer = {
{ 0 }
}
};

// Make sure the SPI speed is slow for this function
dw1000_spi_slow();

dwt_setdblrxbuffmode(TRUE);//FALSE);
// FIXME: Is the double receiver buffer necessary / useful?
//dwt_setdblrxbuffmode(TRUE);//FALSE);
dwt_enableautoack(DW1000_ACK_RESPONSE_TIME);

// Make SPI fast now that everything has been setup
Expand Down
19 changes: 10 additions & 9 deletions software/module/firmware/app_standard_resp.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,20 @@ void resp_rxcallback (const dwt_cb_data_t *rxd, uint8_t * buf, uint64_t dw_rx_ti

// Record the EUI of the tag so that we don't get mixed up
memcpy(sr_scratch->pp_anc_final_pkt.ieee154_header_unicast.destAddr, rx_poll_pkt->header.sourceAddr, 8);

// Record which ranging subsequence the tag is on
sr_scratch->ranging_broadcast_ss_num = rx_poll_pkt->subsequence;
// Record the timestamp. Need to subtract off the TX+RX delay from each recorded
// timestamp.

// Record the timestamp. Need to subtract off the TX+RX delay from each recorded timestamp.
sr_scratch->pp_anc_final_pkt.first_rxd_toa = dw_rx_timestamp - standard_get_rxdelay_from_subsequence(sr_scratch->ranging_broadcast_ss_num);
sr_scratch->pp_anc_final_pkt.first_rxd_idx = sr_scratch->ranging_broadcast_ss_num;
sr_scratch->pp_anc_final_pkt.TOAs[sr_scratch->ranging_broadcast_ss_num] =
(dw_rx_timestamp - standard_get_rxdelay_from_subsequence(sr_scratch->ranging_broadcast_ss_num)) & 0xFFFF;
// Also record parameters the tag has sent us about how to respond
// (or other operational parameters).
sr_scratch->ranging_operation_config.reply_after_subsequence = rx_poll_pkt->reply_after_subsequence;
sr_scratch->ranging_operation_config.resp_reply_window_in_us = rx_poll_pkt->anchor_reply_window_in_us;
sr_scratch->ranging_operation_config.resp_reply_slot_time_in_us = rx_poll_pkt->anchor_reply_slot_time_in_us;

sr_scratch->pp_anc_final_pkt.TOAs[sr_scratch->ranging_broadcast_ss_num] = (dw_rx_timestamp - standard_get_rxdelay_from_subsequence(sr_scratch->ranging_broadcast_ss_num)) & 0xFFFF;

// Also record parameters the tag has sent us about how to respond (or other operational parameters).
sr_scratch->ranging_operation_config.reply_after_subsequence = NUM_RANGING_BROADCASTS - 1; //rx_poll_pkt->reply_after_subsequence;
sr_scratch->ranging_operation_config.resp_reply_window_in_us = RANGING_LISTENING_WINDOW_US; //rx_poll_pkt->anchor_reply_window_in_us;
sr_scratch->ranging_operation_config.resp_reply_slot_time_in_us = RANGING_LISTENING_SLOT_US; //rx_poll_pkt->anchor_reply_slot_time_in_us;

// Update the statistics we keep about which antenna
// receives the most packets from the tag
Expand Down
4 changes: 4 additions & 0 deletions software/module/firmware/dw1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,10 @@ dw1000_err_e dw1000_configure_settings () {
// Set this node's ID and the PAN ID for our DW1000 ranging system
uint8_t eui_array[8];
dw1000_read_eui(eui_array);

// FIXME: Set EUI in Flash directly
eui_array[0] = APP_EUI_FIRST_BYTE;

dwt_seteui(eui_array);
dwt_setpanid(MODULE_PANID);

Expand Down
3 changes: 3 additions & 0 deletions software/module/firmware/firmware.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ typedef enum {
/******************************************************************************/
#define MODULE_PANID 0x6611

// FIXME: Put correct EUI in Flash
#define APP_EUI_FIRST_BYTE 0x01

/******************************************************************************/
// I2C for the application
/******************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion software/module/firmware/module_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define DW1000_SFD_TO (64 + 1 + 8 - 8) /* (Preamble length + 1 + SFD length - PAC size) */
#define RANGING_BROADCASTS_PERIOD_US 1000
#define RANGING_LISTENING_WINDOW_US 8000
#define RANGING_LISTENING_WINDOW_PADDING_US 2000 // This must be large enough so that setup can always occur, even for small EUIs (which influence the random state of the app)
#define RANGING_LISTENING_WINDOW_PADDING_US 1100
#endif

// Protocol adaptation -------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit c52bad6

Please sign in to comment.