| | |
| | | uint16_t heatbeat_count = HEATBEAT_UPDATE_TIME-1 ; |
| | | uint16_t flag_getwgresp = 0; |
| | | int16_t intheight; //气压 |
| | | uint16_t FACHU_FLAG=0; |
| | | extern uint32_t dangqian_frqe; |
| | | uint16_t recnum[3]; |
| | | extern uint32_t freq_list[4]; |
| | |
| | | uint8_t BT_NUM=0; |
| | | extern uint16_t report_ancdist[ANC_MAX_NUM],report_ancid[ANC_MAX_NUM]; |
| | | extern uint8_t bat_percent; |
| | | extern int32_t tagdist_list[TAG_NUM_IN_SYS]; |
| | | extern uint16_t tagid_list[TAG_NUM_IN_SYS]; |
| | | void LoraReportPoll(void) |
| | | { |
| | | // delay_ms(100); |
| | |
| | | |
| | | LoraReportFreqPoll(); |
| | | flag_getwgresp = 0; |
| | | // wg_report_freq = REPORT_MANGE_CHANNEL_FRQ; |
| | | //Lora_init(); |
| | | uint32_t para; |
| | | |
| | | para=freq_list[2] * 100000; |
| | | |
| | | // wg_report_freq = REPORT_MANGE_CHANNEL_FRQ; |
| | | // rf_set_sf(REPORT_CHANNEL_SF); |
| | | SwitchLoraSettings(para,REPORT_CHANNEL_SF,0); |
| | | SwitchLoraSettings(wg_report_freq,REPORT_CHANNEL_SF,g_com_map[LORA_POWER]); |
| | | //rf_set_default_para(wg_report_freq,REPORT_CHANNEL_SF); |
| | | // SwitchLoraSettings(wg_report_freq,REPORT_CHANNEL_SF,g_com_map[LORA_POWER]); |
| | | // dangqian_frqe=rf_read_freq(); |
| | |
| | | // memcpy(&report_ancdist,test_temp2,10); |
| | | |
| | | 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); |
| | | // memcpy(&lora_sendbuffer[ANCID_IDX],report_ancid,report_ancnum*2); |
| | | // memcpy(&lora_sendbuffer[ANCID_IDX+report_ancnum*2],report_ancdist,report_ancnum*2); |
| | | memcpy(&lora_sendbuffer[ANCID_IDX],tagid_list,report_ancnum*2); |
| | | memcpy(&lora_sendbuffer[ANCID_IDX+report_ancnum*2],tagdist_list,report_ancnum*2); |
| | | // tagdist_list[taglist_pos]tagid_list |
| | | |
| | | uint8_t LORA_RETRANSNUSSION_BT=0; |
| | | BT_NUM=DMA_RXBuf_BT[0]; |
| | | if(0<BT_NUM&&BT_NUM<11) |
| | |
| | | Radio.Send(lora_sendbuffer,ANCID_IDX+report_ancnum*4+BT_NUM*4+2); |
| | | } |
| | | |
| | | |
| | | FACHU_FLAG++; |
| | | // LORA_3029_SINGLE_SEND(lora_sendbuffer,ANCID_IDX+report_ancnum*4+BT_NUM*4+4,0); |
| | | memset(DMA_RXBuf_BT, 0,200); |
| | | memset(&lora_sendbuffer[ANCID_IDX],0,200); |
| | |
| | | if(lora_send_count++%10==0||lora_jianting_flag) |
| | | { |
| | | lora_tx_flag=0; |
| | | // Anchor_RecNearPoll(); |
| | | #ifdef GROUPID_SWITCH |
| | | if(rec_secdelay>0) |
| | | { |
| | |
| | | uint16_t BufferSize = BUFFER_SIZE; |
| | | uint16_t CRC16=0; |
| | | uint16_t DEST_ID=0; |
| | | uint16_t JIESHOU_FLAG=0; |
| | | uint8_t shengji_flag; |
| | | int8_t RssiValue = 0; |
| | | int8_t SnrValue = 0; |
| | |
| | | void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) |
| | | { |
| | | |
| | | |
| | | uint16_t checksum1; |
| | | // LORA_LED_ON; |
| | | uint16_t checksum1; |
| | | BufferSize = size; |
| | | memcpy( RX_Buffer, payload, BufferSize ); |
| | | RssiValue = rssi; |
| | |
| | | if(RX_Buffer[MSG_TYPE_IDX]==LORA_MSGTYPE_WGRESPTAG) |
| | | { |
| | | checksum1=Checksum_u16(RX_Buffer,BufferSize-2); |
| | | |
| | | JIESHOU_FLAG++; |
| | | memcpy(&DEST_ID,&RX_Buffer[DEST_ID_IDX],2); |
| | | memcpy(&CRC16,&RX_Buffer[BufferSize-2],2); |
| | | if(!memcmp(&checksum1,&RX_Buffer[BufferSize-2],2)) |
| | |
| | | switch(RX_Buffer[PWTAG_RW_FLAG_IDX]) |
| | | { |
| | | case WGRSP_RWTAG_NONE: |
| | | wg_report_freq = RX_Buffer[POLL_FREQ_IDX]+400; |
| | | memcpy(&rec_delaytime,&RX_Buffer[NEXTPOLL_TIME_IDX],2); |
| | | if(report_ancnum<2) |
| | | { |
| | | datalen_offset = report_ancnum*85; |
| | | }else{ |
| | | datalen_offset = (report_ancnum-1)*46+85; |
| | | } |
| | | rec_secdelay = RX_Buffer[PWTAG_SECDELAY_IDX]; |
| | | if(BufferSize!=13||rec_secdelay>20) |
| | | { |
| | | rec_secdelay = 0; |
| | | } |
| | | sleep_time_count = rec_delaytime - delaytime-datalen_offset; |
| | | while(sleep_time_count>=1000) |
| | | sleep_time_count-=1000; |
| | | sleep_timer_start(sleep_time_count); |
| | | // LORA_LED_OFF; |
| | | // wg_report_freq = RX_Buffer[POLL_FREQ_IDX]+400; |
| | | // memcpy(&rec_delaytime,&RX_Buffer[NEXTPOLL_TIME_IDX],2); |
| | | // if(report_ancnum<2) |
| | | // { |
| | | // datalen_offset = report_ancnum*85; |
| | | // }else{ |
| | | // datalen_offset = (report_ancnum-1)*46+85; |
| | | // } |
| | | // rec_secdelay = RX_Buffer[PWTAG_SECDELAY_IDX]; |
| | | // if(BufferSize!=13||rec_secdelay>20) |
| | | // { |
| | | // rec_secdelay = 0; |
| | | // } |
| | | // sleep_time_count = rec_delaytime - delaytime-datalen_offset; |
| | | // while(sleep_time_count>=1000) |
| | | // sleep_time_count-=1000; |
| | | // sleep_timer_start(sleep_time_count); |
| | | |
| | | break; |
| | | case WGRSP_RWTAG_READ: |
| | |
| | | Radio.Rx(0); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | void OnTxTimeout( void ) |