| | |
| | | extern uint32_t freq_list[4]; |
| | | extern uint8_t DMA_RXBuf_BT[200]; |
| | | extern uint8_t report_ancnum; |
| | | extern uint8_t report_ancnum_bt; |
| | | uint32_t BT_SEND_flag=0; |
| | | uint8_t BT_NUM=0; |
| | | void LoraReportPoll(void) |
| | | { |
| | | // delay_ms(100); |
| | | uint8_t report_ancnum_bt=0; |
| | | |
| | | #ifdef _USE_BAR |
| | | GetPressAndHeight(); |
| | | intheight = Height*100; |
| | |
| | | } |
| | | } |
| | | |
| | | if(report_ancnum>LORA_REPORT_MAXANC_NUM) //考虑lora传输时间,最多发送10个基站数据。 |
| | | report_ancnum = LORA_REPORT_MAXANC_NUM; |
| | | if(report_ancnum>LORA_REPORT_MAXANC_NUM) //考虑lora传输时间,最多发送10个基站数据。 |
| | | { |
| | | report_ancnum = LORA_REPORT_MAXANC_NUM; |
| | | } |
| | | |
| | | #ifdef USE_GPS |
| | | lora_sendbuffer[MSG_TYPE_IDX] = LORA_MSGTYPE_TAGMSGTOWG_GPS; |
| | | lora_sendbuffer[MSG_LENGTH] = 4*report_ancnum+30; |
| | | #else |
| | | lora_sendbuffer[MSG_TYPE_IDX] = LORA_MSGTYPE_TAGMSGTOWG; |
| | | lora_sendbuffer[MSG_LENGTH] = 4*report_ancnum+4*report_ancnum_bt+ANCID_IDX; |
| | | lora_sendbuffer[MSG_LENGTH] = 4*report_ancnum+ANCID_IDX; |
| | | #endif |
| | | memcpy(&lora_sendbuffer[SOURCE_ID_IDX],&g_com_map[DEV_ID],2); |
| | | memcpy(&lora_sendbuffer[DEST_ID_IDX],&wg_report_id,2); |
| | | lora_sendbuffer[SEQNUM_IDX] = seq_num++; |
| | | lora_sendbuffer[BAT_IDX] = bat_percent; |
| | | //GET_USERKEY这个是那个lora——busy那个引脚 |
| | | |
| | | // lora_sendbuffer[STATE_IDX]=0x01; |
| | | // lora_sendbuffer[GATEWAY_CHANL]=0x02; |
| | | // lora_sendbuffer[CHANL_NUM]=0x03; |
| | | // lora_sendbuffer[STATE_IDX] = !GET_USERKEY|stationary_flag<<1; |
| | | #ifdef USE_GPS |
| | | memcpy(&lora_sendbuffer[GPS_JINGDU_IDX],&gps_jingdu,8); |
| | |
| | | lora_sendbuffer[ANCNUM_IDX] = report_ancnum; |
| | | memcpy(&lora_sendbuffer[ANCID_IDX],report_ancid,report_ancnum*2); |
| | | memcpy(&lora_sendbuffer[ANCID_IDX+report_ancnum*2],report_ancdist,report_ancnum*2); |
| | | |
| | | uint8_t LORA_RETRANSNUSSION_BT=0; |
| | | LORA_RETRANSNUSSION_BT=ANCID_IDX+report_ancnum*2+1; |
| | | uint8_t LORA_RETRANSNUSSION_BT=0; |
| | | BT_NUM=DMA_RXBuf_BT[0]; |
| | | if(0<BT_NUM&&BT_NUM<11) |
| | | { |
| | | lora_sendbuffer[MSG_TYPE_IDX] = LORA_MSGTYPE_TAGMSGTOWG_BT; |
| | | LORA_RETRANSNUSSION_BT=ANCID_IDX+report_ancnum*4; |
| | | //LORA_RETRANSNUSSION_BT report_ancnum_bt |
| | | lora_sendbuffer[LORA_RETRANSNUSSION_BT] = 0x2D; //蓝牙上传标识符 |
| | | DMA_RXBuf_BT[0]=report_ancnum_bt; //蓝牙基站数量 |
| | | memcpy(&lora_sendbuffer[LORA_RETRANSNUSSION_BT],&DMA_RXBuf_BT[1],report_ancnum_bt*2); //基站ID |
| | | memcpy(&lora_sendbuffer[LORA_RETRANSNUSSION_BT+report_ancnum_bt*2],&DMA_RXBuf_BT[1+report_ancnum_bt*2],report_ancnum_bt*2);//基站距离 |
| | | lora_sendbuffer[LORA_RETRANSNUSSION_BT] = 0x2D; //蓝牙上传标识符 |
| | | memcpy(&lora_sendbuffer[LORA_RETRANSNUSSION_BT+1],&DMA_RXBuf_BT[0],BT_NUM*2+1); //基站ID |
| | | memcpy(&lora_sendbuffer[LORA_RETRANSNUSSION_BT+BT_NUM*2+2],&DMA_RXBuf_BT[1+BT_NUM*2],BT_NUM*2);//基站距离 |
| | | lora_sendbuffer[MSG_LENGTH] = 4*report_ancnum+4*BT_NUM+ANCID_IDX+2; |
| | | } |
| | | if(lora_sendbuffer[LORA_RETRANSNUSSION_BT]==0x2D) |
| | | { |
| | | checksum = Checksum_u16(lora_sendbuffer,4*report_ancnum_bt+4*report_ancnum+ANCID_IDX+1); |
| | | memcpy(&lora_sendbuffer[ANCID_IDX+report_ancnum_bt*4+report_ancnum*4+2],&checksum,2); |
| | | checksum = Checksum_u16(lora_sendbuffer,4*BT_NUM+4*report_ancnum+ANCID_IDX+2); |
| | | memcpy(&lora_sendbuffer[ANCID_IDX+BT_NUM*4+report_ancnum*4+2],&checksum,2); |
| | | BT_SEND_flag++; |
| | | LORA_3029_SINGLE_SEND(lora_sendbuffer,ANCID_IDX+report_ancnum*4+BT_NUM*4+4,0); |
| | | } |
| | | else |
| | | { |
| | | checksum = Checksum_u16(lora_sendbuffer,4*report_ancnum+ANCID_IDX); |
| | | memcpy(&lora_sendbuffer[ANCID_IDX+report_ancnum*4],&checksum,2); |
| | | LORA_3029_SINGLE_SEND(lora_sendbuffer,ANCID_IDX+report_ancnum*4+BT_NUM*4+2,0); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //rf_enter_continous_tx(); |
| | | // LORA_3029_SEND(lora_sendbuffer,ANCID_IDX+report_ancnum*4+2); |
| | | LORA_3029_SINGLE_SEND(lora_sendbuffer,ANCID_IDX+report_ancnum*4+report_ancnum_bt*2+4,0); |
| | | |
| | | // rf_single_tx_data(lora_sendbuffer,ANCID_IDX+report_ancnum*4+2,2); |
| | | //rf_enter_continous_rx(); |
| | | |
| | | |
| | | |
| | | memset(DMA_RXBuf_BT, 0,200); |
| | | memset(&lora_sendbuffer[ANCID_IDX],0,200); |
| | | //LED_TB_ON; |
| | | // bat_percent=Get_Battary(); |
| | | |
| | | |
| | | for(uint8_t i=0;i<3;i++) |
| | | recnum[i] = 0; |
| | |
| | | // group_min_dist[group_id] = 0xffff; |
| | | // Radio.Standby(); |
| | | //rf_antenna_close(); |
| | | rf_set_mode(RF_MODE_STB3); |
| | | uint32_t para; |
| | | // rf_set_mode(RF_MODE_STB3); |
| | | // uint32_t para; |
| | | // frqe=((UWB_CHANNEL_FRQ+group_id)*100000); |
| | | para=freq_list[1] * 100000; |
| | | // para=freq_list[1] * 100000; |
| | | //// rf_set_default_para(frqe,UWB_CHANNEL_SF); |
| | | // rf_set_carrier_wave_off(); |
| | | // rf_set_carrier_wave_on(); |
| | | rf_set_freq(para); |
| | | rf_set_sf(5); |
| | | // rf_set_tx_power(para); |
| | | // rf_set_carrier_wave_freq(freq_list[1] * 100000); |
| | | //SwitchLoraSettings(UWB_CHANNEL_FRQ+group_id,UWB_CHANNEL_SF,0); |
| | | dangqian_frqe=rf_read_freq(); |
| | | //// rf_set_carrier_wave_on(); |
| | | // rf_set_freq(para); |
| | | // rf_set_sf(5); |
| | | //// rf_set_tx_power(para); |
| | | //// rf_set_carrier_wave_freq(freq_list[1] * 100000); |
| | | // //SwitchLoraSettings(UWB_CHANNEL_FRQ+group_id,UWB_CHANNEL_SF,0); |
| | | // dangqian_frqe=rf_read_freq(); |
| | | // LoraSendComMap(WGRSP_RWTAG_READ); |
| | | |
| | | //delay_us(5000); |