| | |
| | | extern uint16_t mubiao_anchor_ID; |
| | | uint8_t Lora_qingqiu_flag; |
| | | extern uint16_t Lora_qingqiu_bao; |
| | | uint8_t shengji_flag; |
| | | extern uint8_t Dtu_shengji_jindu[20]; |
| | | static void rx_int_callback(struct MAC_HW_REPORT_T *rx_report) |
| | | { uint8_t valid_sts=0; |
| | | uint16_t checksum1 = 0,dest_id; |
| | |
| | | receive_flag=1; |
| | | // uart_send(UART_ID0, rx_buf,rx_length, NULL); |
| | | gpio_pin_toggle(IO_PIN_4); |
| | | if(rx_buf[MESSAGE_TYPE_IDX]==MBX_POLL) |
| | | if(rx_buf[MESSAGE_TYPE_IDX]==MBX_POLL&&!shengji_flag) |
| | | { |
| | | Anchor_App(); |
| | | } |
| | |
| | | { |
| | | if(!memcmp(&dev_id,&dest_id,2)/*||dest_id==0xffff||(dest_id==0xfffe&&get_channel==5)*/) |
| | | { |
| | | shengji_flag=1; |
| | | switch(rx_buf[MSG_TYPE_IDX]) |
| | | { |
| | | case LORA_MSGTYPE_UPDATE_CONFIRM: |
| | |
| | | break; |
| | | |
| | | case 0x99: |
| | | LOG_INFO(TRACE_MODULE_APP, "收到结束升级请求\r\n",Lora_qingqiu_bao); |
| | | delay_ms(500); |
| | | // LOG_INFO(TRACE_MODULE_APP, "收到结束升级请求\r\n",Lora_qingqiu_bao); |
| | | delay_ms(200); |
| | | Dtu_shengji_jindu[4]=100; |
| | | memcpy(&Dtu_shengji_jindu[5],&mubiao_anchor_ID,2); |
| | | uart_send(UART_ID0, Dtu_shengji_jindu,9, NULL); |
| | | |
| | | delay_ms(1000); |
| | | // Lora_upanc_flag=0; |
| | | Lora_qingqiu_flag=0; |
| | | NVIC_SystemReset(); |
| | |
| | | //void TagListUpdate(void) |
| | | //{ |
| | | // uint8_t i,j=0; |
| | | // for(i=0; i<anchordata_num; i++) |
| | | // for(i=0; i<taglist_num; i++) |
| | | // { |
| | | // if(tagofflinetime[i]++<QUIT_SLOT_TIME) |
| | | // { |
| | |
| | | // tagofflinetime[j++]=tagofflinetime[i]; |
| | | // } |
| | | // } |
| | | // anchordata_num=j; |
| | | // taglist_num=j; |
| | | //} |
| | | void TagListUpdate(void) |
| | | { |
| | | uint16_t i,j=0,k=0; |
| | | for(i=0; i<taglist_num; i++) |
| | | { |
| | | if(tagofflinetime[i]++<TAG_KEEPTIMES) |
| | | if(tagofflinetime[i]++<10) |
| | | { |
| | | tagid_list[j]=tagid_list[i]; |
| | | tagdist_list[j] = tagdist_list[i]; |
| | | anchordata_bat[j]=anchordata_bat[i];//电量随之更新 |
| | | anchordata_bat[j]=anchordata_bat[i];//电量随之更新 |
| | | anchordata_version[j]=anchordata_version[i]; |
| | | tagofflinetime[j++]=tagofflinetime[i]; |
| | | } |
| | |
| | | if(uwb_losttimer>g_com_map[UWB_RNAGE_TIME]) |
| | | uwb_losttimer=g_com_map[UWB_RNAGE_TIME]+1;//防止溢出 |
| | | } |
| | | uint8_t uwbsend[200]; |
| | | uint8_t uwbsend[1000]; |
| | | |
| | | void UWBIdleTask(void) |
| | | { |
| | | |
| | | if(HIDO_TimerGetTick()-uwbtasktimer >=1) |
| | | { |
| | | |
| | | for(uint16_t i=0;i<taglist_num-1;i++) |
| | | { |
| | | for(uint16_t j=0;j<taglist_num-1-i;j++) |
| | | { |
| | | if(tagdist_list[j]>tagdist_list[j+1]) |
| | | { |
| | | uint16_t id,dist,version; |
| | | uint8_t bat; |
| | | id = tagid_list[j]; |
| | | dist = tagdist_list[j]; |
| | | version = anchordata_version[j]; |
| | | tagid_list[j] = tagid_list[j+1]; |
| | | tagdist_list[j] = tagdist_list[j+1]; |
| | | anchordata_version[j] = anchordata_version[j+1]; |
| | | tagid_list[j+1] = id; |
| | | tagdist_list[j+1] = dist; |
| | | anchordata_version[j+1] = version; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // if(taglist_num>6) |
| | | // { |
| | | // taglist_num=6; |
| | | // } |
| | | uwbtasktimer = HIDO_TimerGetTick(); |
| | | UWBOneSecondTask(); |
| | | uwbsend[0]=0x55; |
| | |
| | | memcpy(&uwbsend[4],&tagid_list,taglist_num*2); |
| | | memcpy(&uwbsend[4+taglist_num*2],&tagdist_list,taglist_num*2); |
| | | memcpy(&uwbsend[4+taglist_num*4],&anchordata_version,taglist_num*2); |
| | | uart_send(UART_ID0, uwbsend,taglist_num*6+4, NULL); |
| | | taglist_num=0; |
| | | // for(int i=0;i<anchordata_num;i++) |
| | | // { |
| | | // LOG_INFO(TRACE_MODULE_APP,"当前测距基站ID:%x,距离:%d.\r\n",tagid_list[0],tagdist_list[0]); |
| | | // } |
| | | // uart_send(UART_ID0, uwbsend,taglist_num*6+4, NULL); |
| | | // taglist_num=0; |
| | | LOG_INFO(TRACE_MODULE_APP,"当前测距基站数量%d.\r\n",taglist_num); |
| | | for(int i=0;i<taglist_num;i++) |
| | | { |
| | | LOG_INFO(TRACE_MODULE_APP,"当前测距基站ID:%x,距离:%d.\r\n",tagid_list[i],tagdist_list[i]); |
| | | } |
| | | } |
| | | } |
| | | int uwb_app_poll(void) |
| | |
| | | current_count=phy_timer_count_get(); |
| | | while(mac_is_busy()) |
| | | { |
| | | Calibration_Time(); |
| | | // Calibration_Time(); |
| | | IdleTask(); |
| | | current_count=phy_timer_count_get(); |
| | | if(current_count>end_receive_count&¤t_count<end_receive_count+HALF_SECOND_TIME) |
| | |
| | | phy_rx_ant_mode_set(RX_ANT_PORTS_COMBINATION); |
| | | #endif |
| | | // Set calibration parameters |
| | | config.phy_cfg.ch_num=g_com_map[NEARBASE_ID1]; |
| | | // config.phy_cfg.ch_num=g_com_map[NEARBASE_ID1]; |
| | | uwb_calibration_params_set(config.phy_cfg.ch_num); |
| | | #ifndef STS_MODE |
| | | // set advanced parameters |