|
定位结果最终通过如下代码段发送给基站,如果是中间通信过程,请仔细阅读固件代码- //location
- {
- uint8 len = 0;
- angle_msg[LOCATION_FLAG_IDX] = 1;
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = 'm';
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = 'r';
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = 0x02;
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = TAG_ID;//TAG ID
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = (uint8)(framenum&0xFF);
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = (uint8)((framenum>>8)&0xFF);
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = (uint8)((distance1/10)&0xFF);
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = (uint8)((distance1/10 >>8)&0xFF);
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = (uint8)((distance2/10)&0xFF);
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = (uint8)((distance2/10 >>8)&0xFF);
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = (uint8)((distance3/10)&0xFF);
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = (uint8)((distance3/10 >>8)&0xFF);
- if(ANCHOR_MAX_NUM > 3)
- {
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = (uint8)((Anthordistance[3]/10)&0xFF);
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = (uint8)((Anthordistance[3]/10 >>8)&0xFF);
- }
- else
- {
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = (uint8)((distance1/10)&0xFF);
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = (uint8)((distance1/10 >>8)&0xFF);
- }
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = '\n';
- angle_msg[LOCATION_INFO_START_IDX + (len++)] = '\r';
- angle_msg[LOCATION_INFO_LEN_IDX] = len;
- //MAX LEN
- if(LOCATION_INFO_START_IDX + len -2 >ANGLE_MSG_MAX_LEN)
- {
- while(1);
- }
- //USART_puts((char*)angle_msg,len);
- }
- #endif
- //only anthor0 recive angle message
- angle_msg[ALL_MSG_SN_IDX] = framenum;
- angle_msg[ALL_MSG_TAG_IDX] = TAG_ID;
- dwt_writetxdata(sizeof(angle_msg), angle_msg, 0);
- dwt_writetxfctrl(sizeof(angle_msg), 0);
- /* Start transmission, indicating that a response is expected so that reception is enabled automatically after the frame is sent and the delay
- * set by dwt_setrxaftertxdelay() has elapsed. */
- dwt_starttx(DWT_START_TX_IMMEDIATE );
- while (!(dwt_read32bitreg(SYS_STATUS_ID) & SYS_STATUS_TXFRS))
- { };
复制代码
|
|