| | |
| | | uint8_t phy_work_mode; /* PHY_TX / PHY_RX / PHT_TX|PHY_RX */ |
| | | struct UWB_CONFIG_T phy_cfg; |
| | | }; |
| | | |
| | | extern uint8_t uwb_ch; |
| | | static struct mk_uwb_configure config = { |
| | | .phy_work_mode = (uint8_t)(PHY_TX | PHY_RX), |
| | | .phy_cfg.ch_num = 5, /* Channel number. */ |
| | |
| | | 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; |
| | |
| | | rssi = rx_report->rssi; |
| | | receive_flag=1; |
| | | // uart_send(UART_ID0, rx_buf,rx_length, NULL); |
| | | if(rx_buf[MESSAGE_TYPE_IDX]==MBX_POLL) |
| | | gpio_pin_toggle(IO_PIN_4); |
| | | if((rx_buf[MESSAGE_TYPE_IDX]==MBX_POLL||rx_buf[MESSAGE_TYPE_IDX]==DISCOVERPOLL2)&&!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(); |
| | |
| | | // } |
| | | } |
| | | } |
| | | |
| | | |
| | | #ifdef STS_MODE |
| | | valid_sts= sts_valid_check(); |
| | | if (valid_sts) |
| | |
| | | // } |
| | | // anchordata_num=j; |
| | | //} |
| | | int8_t test22,test33; |
| | | void TagListUpdate(void) |
| | | { |
| | | uint16_t i,j=0,k=0; |
| | |
| | | if(cmd_flag==0) |
| | | { |
| | | temp_count2=poll_rx_en_start_u32; |
| | | |
| | | group_id=0xff; |
| | | memcpy(&send_buffer[GROUP_ID_IDX],&group_id,1);//组id |
| | | memcpy(&send_buffer[ANCHOR_ID_IDX],&dev_id,2);//自身id |
| | | memcpy(&send_buffer[TAG_ID_IDX],&tag_id_recv,2);//接受者id |
| | | send_buffer[MESSAGE_TYPE_IDX]=MBX_RESPONSE; |
| | | send_buffer[MESSAGE_TYPE_IDX]=POS_RESPONSE; |
| | | |
| | | // if(rec_nearbase_num == ancrec_nearbasepos)//抢占模式自己为新基站 |
| | | // { |
| | |
| | | temp_count3= phy_timer_count_get(); |
| | | flag_temp2=uwb_tx(send_buffer, 40,1 ,resp_tx_en_start_u32);//立即发送测试size大小 |
| | | tagofflinetime[taglist_pos] = 0;//更新标签通信 |
| | | test33++; |
| | | // temp_count1=phy_timer_count_get(); |
| | | //while(mac_is_busy()); |
| | | //gpio_pin_clr(SCL_PIN); |
| | |
| | | |
| | | 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; |
| | |
| | | { |
| | | UWBIdleTask(); |
| | | } |
| | | int32_t u32_rec_ancdistlist[TAG_NUM_IN_SYS]; |
| | | int Anchor_App(void) |
| | | { |
| | | uint8_t i; |
| | | uint16_t tempid; |
| | | if(group_id==rx_buf[GROUP_ID_IDX]&&rx_buf[MESSAGE_TYPE_IDX] == MBX_POLL)//判断是否是和自己是同一组通讯的且为poll包 |
| | | { flag_recsuccess = 1; |
| | | wltag_state=RANGE;//成功后从search切换为range |
| | | memcpy(&g_com_receive_id,&rx_buf[TAG_ID_IDX],2); |
| | |
| | | uwb_losttimer=0;//成功测距清0 lost时间 |
| | | frame_seq_nb2 = rx_buf[SEQUENCE_IDX];//获取包序 |
| | | battary = rx_buf[BATTARY_IDX]; |
| | | rec_nearbase_num=rx_buf[FZ_NEARBASENUM_INDEX]; //标签传过来的他与基站交互的基站id数目 |
| | | rec_nearbase_num=rx_buf[18]; //标签传过来的他与基站交互的基站id数目 |
| | | memcpy(&tag_id_recv,&rx_buf[TAG_ID_IDX],2); |
| | | memcpy(rec_ancidlist,&rx_buf[FZ_NEARBASEID_INDEX],2*rec_nearbase_num); |
| | | memcpy(rec_ancdistlist,&rx_buf[FZ_NEARBASEID_INDEX+2*rec_nearbase_num],2*rec_nearbase_num); |
| | | memcpy(&rec_antdelay,&rx_buf[FZ_NEARBASEID_INDEX+rec_nearbase_num*4],2); |
| | | // for(i=0; i<rec_nearbase_num; i++) |
| | | // { |
| | | // if(rec_ancidlist[i] == dev_id) |
| | | // { temp_recdist_before_offset=rec_ancdistlist[i]; |
| | | // rec_ancdistlist[i]+=(int16_t)g_com_map[DIST_OFFSET]; |
| | | // PushAnchorDataArray(tag_id_recv,rec_ancdistlist[i],battary); |
| | | // } |
| | | // } |
| | | // for(i=0; i<rec_nearbase_num; i++) |
| | | // { |
| | | // memcpy(&tempid,&rx_buf[FZ_NEARBASEID_INDEX+i*2],2); |
| | | // if(tempid==dev_id)//也是比id如果有就更新没有就抢占 |
| | | // { |
| | | // seize_anchor=0; //非抢占。已存在列表中 |
| | | // Anchor_RecNearPoll(i); |
| | | // break; |
| | | // } |
| | | // } |
| | | memcpy(rec_ancidlist,&rx_buf[19+2],2*rec_nearbase_num); |
| | | |
| | | // if(i==rec_nearbase_num) |
| | | // { |
| | | // seize_anchor=1; //抢占anchor |
| | | // Anchor_RecNearPoll(i); |
| | | // } |
| | | memcpy(u32_rec_ancdistlist,&rx_buf[19+4+2*rec_nearbase_num],4*rec_nearbase_num); |
| | | for (int i = 0; i < rec_nearbase_num+1; i++) |
| | | { |
| | | rec_ancdistlist[i] = (int16_t)(u32_rec_ancdistlist[i] & 0xFFFF); |
| | | } |
| | | test22++; |
| | | // memcpy(rec_ancdistlist,&rx_buf[FZ_NEARBASEID_INDEX+2*rec_nearbase_num],2*rec_nearbase_num); |
| | | // memcpy(&rec_antdelay,&rx_buf[FZ_NEARBASEID_INDEX+rec_nearbase_num*4],2); |
| | | |
| | | taglist_pos=CmpTagInList(tag_id_recv); |
| | | if(taglist_num>=ANC_MAX_NUM) |
| | | return 0; |
| | | for(i=0; i<rec_nearbase_num; i++) |
| | | { |
| | | memcpy(&tempid,&rx_buf[FZ_NEARBASEID_INDEX+i*2],2); |
| | | memcpy(&tempid,&rx_buf[19+2+i*2],2); |
| | | if(tempid==dev_id) |
| | | { |
| | | Anchor_RecNearPoll(i); |
| | |
| | | phy_rx_ant_mode_set(RX_ANT_PORTS_COMBINATION); |
| | | #endif |
| | | // Set calibration parameters |
| | | // 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 |