//#include "lora_3029.h" //#include "mk_spi.h" //#include "global_param.h" //#include "pan_port.h" //#include "pan_rf.h" //#include "dw_app_anchor.h" //#include "HIDO_TypeDef.h" ////#include "WS2812.h" ////#include "pan_port.h" ////#include "pan_param.h" ////#include "pan_rf.h" ////#define RX_TIMEOUT_VALUE 1000 ////extern LPTIM_HandleTypeDef hlptim1; ///***lora½ÓÊÕ£¬·¢ËͱäÁ¿¶¨Òå******/ //extern uint32_t current_count; //extern uint32_t dev_id; //uint8_t yuyin_no_sleep_flag,no_rx_flag; //uint8_t lora_up_rec_flag; //static uint16_t source_id; ///***lora½ÓÊÕ£¬·¢ËͱäÁ¿¶¨Òå******/ //uint32_t wg_lost_count = 10; //static uint8_t tx_buf[10] = {0x55, 0x44, 0x33, 0x22, 0x11}; //static uint8_t rx_buf[10] = {0x00}; ////extern uint32_t uwbled,gpsled,loraled,powerled; //extern uint8_t bat_percent,taglist_num; ////uint8_t report_ancnum; ////uint16_t report_ancdist[ANC_MAX_NUM],report_ancid[ANC_MAX_NUM]; //extern void spi_transfer_callback(void *dev, uint32_t err_code); //extern uint16_t ancidlist_rec[TAG_NUM_IN_SYS],ancidlist_send[TAG_NUM_IN_SYS],rec_ancidlist[TAG_NUM_IN_SYS]; //extern uint8_t report_ancnum; //extern uint16_t report_ancdist[ANC_MAX_NUM],report_ancid[ANC_MAX_NUM]; ////extern u8 active_flag; ////void LoraInit(void) ////{ //// RadioEvents.TxDone = OnTxDone; //// RadioEvents.RxDone = OnRxDone; //// RadioEvents.TxTimeout = OnTxTimeout; //// RadioEvents.RxTimeout = OnRxTimeout; //// RadioEvents.RxError = OnRxError; //// Radio.Init( &RadioEvents ); //// SwitchLoraSettings(UWB_CHANNEL_FRQ+group_id,UWB_CHANNEL_SF,0); //Çл»lora½ÓÊÕÆµµã //// if(active_flag) //// { //// Radio.Rx( 0 ); //// }else{ //// Radio.Sleep(); //// } ////// Radio.SetRxDutyCycle(RxDutyCycle_RX_time,RxDutyCycle_SLEEP_time); //// ////} //void Lora_init(void) //{ //// rf_write_reg(0x04, 0x55); //// rf_port.spi_readwrite(0x09); //// uint8_t rx_data = 0; // ÓÃÓÚ´æ´¢½ÓÊÕµÄÊý¾Ý //// spi_transfer(SPI_ID0, 0x09, rx_buf, 1, spi_transfer_callback); // uint32_t ret = 0; // uint32_t cnt = 0; // ret=rf_init(); // // set_test_mode1_reg(); // if(ret== 1) // { // //printf("LORA Init Fail"); // while(1); // } // else // { // //printf("LORA Init OK\r\n"); // } //} ////void TagListUpdate(void) ////{ //// uint16_t i,j=0,k=0,temp[TAG_NUM_IN_SYS]; //// for(i=0; iWG_LOST_NOUWB_COUNT) // { // lora_jianting_flag = 0; // } else { // lora_jianting_flag = 1; // } // if(wg_state==WG_Lost) // { // static uint8_t channel_switch_count = 0; // // channel_switch_count = 10; // if(channel_switch_count++>1) // { //// channel_switch_count = 0; //// wg_report_id = DEFAULT_LR_WG_ID; //// wg_report_freq = LR_DATA_CHANNEL_FRQ; //Èç¹û¶ªÊ§Á´½Ó¾Í½øÈëWG¹ÜÀíÐŵÀ¡£ //// wg_report_sf = LR_DATA_CHANNEL_SF; // } // else // { // wg_report_id = DEFAULT_WG_ID; // wg_report_freq = REPORT_MANGE_CHANNEL_FRQ; //Èç¹û¶ªÊ§Á´½Ó¾Í½øÈëWG¹ÜÀíÐŵÀ¡£ // wg_report_sf = REPORT_CHANNEL_SF; //// wg_report_freq = TEST_MANAGE_CHANNEL_FRQ; //// wg_report_sf = TEST_MANAGE_CHANNEL_SF; // } // } else { // if(wg_lost_count>WG_LOST_SWITCH_THRES) // { // wg_state = WG_Lost; // } // } //} //static uint16_t checksum; ////uint16_t wg_report_freq,wg_report_id; //uint8_t lora_sendbuffer[200]; //void LoraHeartBeartPoll(void) //{ //// lora_up_uwb_flag=2; //// rf_set_default_para(); ///*****************************ÐÄÌø°üÉÏ´«ÄÚÈÝ************************************/ // lora_sendbuffer[MSG_TYPE_IDX] = LORA_MSGTYPE_TAGHEARTBEAT; // lora_sendbuffer[MSG_LENGTH] = 14; // memcpy(&lora_sendbuffer[SOURCE_ID_IDX],&g_com_map[DEV_ID],2); // memcpy(&lora_sendbuffer[DEST_ID_IDX],&wg_report_id,2); // memcpy(&lora_sendbuffer[HB_VERSION_IDX],&g_com_map[VERSION],2); // lora_sendbuffer[HB_UWBPOWER_IDX] = g_com_map[POWER]; // lora_sendbuffer[HB_LORAPOWER_IDX] = g_com_map[LORA_POWER]; // checksum = Checksum_u16(lora_sendbuffer,14); // memcpy(&lora_sendbuffer[14],&checksum,2); // LORA_3029_SINGLE_SEND(lora_sendbuffer,16,0); // ///*****************************ÐÄÌø°üÉÏ´«ÄÚÈÝ*************************************/ // //} //#define HEATBEAT_UPDATE_TIME 100 //uint16_t heatbeat_count = HEATBEAT_UPDATE_TIME-1 ; //uint16_t flag_getwgresp = 0; //uint16_t test_temp[10]={0x1306,9688,1000}; //uint16_t test_temp2[10]={0xff,0xcd,0x19}; //int16_t intheight; //ÆøÑ¹ //extern uint32_t dangqian_frqe; //extern uint16_t recnum[3]; //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); //#ifdef _USE_BAR // GetPressAndHeight(); // intheight = Height*100; //#endif //#ifdef _SMT_TEST // printf("ÆøÑ¹Öµ£º%d",intheight); //#endif // TagListUpdate(); // LoraReportFreqPoll(); // flag_getwgresp = 0; // // wg_report_freq = REPORT_MANGE_CHANNEL_FRQ; // //Lora_init(); // uint32_t para; // para=freq_list[2] * 100000; //// rf_set_freq(wg_report_freq*100000); //// rf_set_carrier_wave_off(); //// rf_set_carrier_wave_on(); // rf_set_freq(para); // //rf_set_sf(UWB_CHANNEL_SF); //// rf_set_tx_power(para); //// rf_set_carrier_wave_freq(freq_list[1] * 100000); //// rf_set_freq(para); // rf_set_sf(REPORT_CHANNEL_SF); // //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(); // if(heatbeat_count++>HEATBEAT_UPDATE_TIME && WG_Connected == wg_state) //Èç¹ûÐÄÌø°üµ½´ïÉÏ´«Ê±¼ä£¬²¢ÇÒÍø¹Ø´¦ÓÚÁ´½Ó״̬£¬¾ÍÉÏ´«ÐÄÌø°ü // { // heatbeat_count = 0; // LoraHeartBeartPoll(); // return; // } // for(uint16_t i=0; ireport_ancdist[j+1]) // { // uint16_t id,dist; // uint8_t bat; // id = report_ancid[j]; // dist = report_ancdist[j]; // report_ancid[j] = report_ancid[j+1]; // report_ancdist[j] = report_ancdist[j+1]; // report_ancid[j+1] = id; // report_ancdist[j+1] = dist; // } // } // } // // 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+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); // memcpy(&lora_sendbuffer[GPS_WEIDU_IDX],&gps_jingdu,8); // memcpy(&lora_sendbuffer[GPS_HEIGHT_IDX],&gps_height,8); // lora_sendbuffer[GPS_STATE_IDX] = gps_state; // lora_sendbuffer[GPS_SATEL_NUM_IDX] = gps_satel_num; // lora_sendbuffer[GPS_SPOWER_IDX] = gps_signalpower; // lora_sendbuffer[GPS_CHAFENLINGQI] = gps_chafenlingqi; //#endif // // memcpy(&lora_sendbuffer[BAR_HEIGHT_IDX],&bar_height,2); //// memcpy(&report_ancid,test_temp,10); //// 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); // uint8_t LORA_RETRANSNUSSION_BT=0; // BT_NUM=DMA_RXBuf_BT[0]; // if(00) // { // rec_secdelay--; //// if(lora_jianting_flag) //// { //// if(++group_id>GROUP_NUM) //// { //// group_id = 1; //// } //// t22[ti++] = group_id; //// if(ti>=20) //// ti=0; //// group_min_dist[group_id] = 0xffff; //// Radio.Standby(); //// SwitchLoraSettings(UWB_CHANNEL_FRQ+group_id,UWB_CHANNEL_SF,0); //// Radio.Rx(0); //// } // return; // } //// //ÕÒ3¸öС×éÖÐ×î½ü¾àÀë×î´óµÄС×飬ÉÏ´«±¨ÎĺóÇл»µ½Õâ¸öС×飬ÒòΪÉÏ´«±¨ÎÄ»áʱ¼äÕ¼Óᣠ//// if(group_min_dist[1]>group_min_dist[2]) //Èç¹û1´óÓÚ2 //// { //// group_maxdist_index = group_min_dist[1]>group_min_dist[3]?1:3; //È¡ 1ºÍ3 ×î´óÖµ //// group_mindist_index = group_min_dist[2]group_min_dist[3]?2:3; //È¡ 2ºÍ3 ×î´óÖµ //// group_mindist_index = group_min_dist[1]=20) // ti=0; // // group_min_dist[group_id] = 0xffff; // // Radio.Standby(); // //rf_antenna_close(); //// rf_set_mode(RF_MODE_STB3); //// uint32_t para; //// frqe=((UWB_CHANNEL_FRQ+group_id)*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(); // // LoraSendComMap(WGRSP_RWTAG_READ); // // //delay_us(5000); //// rf_enter_continous_rx(); // //LedTask(); // //LoraHeartBeartPoll(); //// if(rf_continous_tx_send_data(tx_test_buf, TX_LEN) != OK) //// { //// while(1); //// } // // rf_get_mode(); //// LoraReportPoll(); // // LedOff_task(); // } // } // //} //uint8_t TX_RX_SELECT=0; //int LORA_3029_SINGLE_SEND(uint8_t *buffer, uint8_t size,uint8_t time) //{ // if((rf_single_tx_data(lora_sendbuffer,size,time))!= OK) // { // while(1); // } // rf_delay_us(1); // // //rf_enter_single_rx(); // //rf_enter_single_timeout_rx(700); //} //int LORA_3029_CONTINOUS_SEND(uint8_t *buffer, uint8_t size) //{ //}