| | |
| | | break; |
| | | }; |
| | | tagofflinetime[taglist_pos] = 0; |
| | | printf("测距成功,序号%d,距离%d\r\n",frame_seq_nb2,tagdist_list[taglist_pos]); |
| | | delay_ms(10); |
| | | // printf("测距成功,序号%d,距离%d\r\n",frame_seq_nb2,tagdist_list[taglist_pos]); |
| | | // delay_ms(10); |
| | | } |
| | | uint8_t report_ancnum; |
| | | void TagListUpdate(void) |
| | |
| | | dwt_entersleep(); |
| | | |
| | | } |
| | | typedef enum{ WG_Lost, //上报丢失 失去和网关通讯 |
| | | WG_Connected,// 上报中 和网关通讯正常 |
| | | }wg_state_enum; |
| | | static wg_state_enum wg_state = WG_Lost; |
| | | static uint8_t lora_sendbuffer[200]; |
| | | u8 wg_report_lost_count,seq_num; |
| | | wg_state_enum wg_state = WG_Lost; |
| | | uint8_t lora_sendbuffer[200]; |
| | | u8 seq_num; |
| | | extern u8 wg_lost_count; |
| | | uint16_t wg_report_freq,wg_report_id; |
| | | #define WG_LOST_SWITCH_THRES 3 |
| | | void LoraReportFreqPoll(void) |
| | | { |
| | | if(wg_state==WG_Lost) |
| | | { |
| | | wg_report_id = 0xffff; |
| | | wg_report_freq = REPORT_MANGE_CHANNEL_FRQ; //如果丢失链接就进入WG管理信道。 |
| | | }else{ |
| | | if(wg_report_lost_count++>WG_LOST_SWITCH_THRES) |
| | | if(wg_lost_count++>WG_LOST_SWITCH_THRES) |
| | | { |
| | | wg_state = WG_Lost; |
| | | } |
| | | } |
| | | } |
| | | static u16 checksum; |
| | | u8 gps_state,gps_chafenlingqi,gps_satel_num; |
| | | u8 gps_state,gps_chafenlingqi,gps_satel_num,test_num; |
| | | double gps_jingdu,gps_weidu; |
| | | extern u8 bat_percent,stationary_flag; |
| | | int16_t sendcount = 0,tp1; |
| | | void LoraReportPoll(void) |
| | | { |
| | | |
| | | if(sendcount++>0) |
| | | TagListUpdate(); |
| | | |
| | | LoraReportFreqPoll(); |
| | | taglist_num = test_num; |
| | | SwitchLoraSettings(wg_report_freq,REPORT_CHANNEL_SF,g_com_map[LORA_POWER]); |
| | | lora_sendbuffer[MSG_TYPE_IDX] = LORA_MSGTYPE_TAGMSGTOWG; |
| | | lora_sendbuffer[MSG_TYPE_IDX] = LORA_MSGTYPE_TAGMSGTOWG_GPS; |
| | | lora_sendbuffer[MSG_LENGTH] = 4*taglist_num+30; |
| | | memcpy(&lora_sendbuffer[SOURCE_ID_IDX],&g_com_map[DEV_ID],2); |
| | | memcpy(&lora_sendbuffer[DEST_ID_IDX],&wg_report_id,2); |
| | |
| | | lora_sendbuffer[ANCNUM_IDX] = taglist_num; |
| | | memcpy(&lora_sendbuffer[ANCID_IDX],tagid_list,taglist_num*2); |
| | | memcpy(&lora_sendbuffer[ANCID_IDX+taglist_num*2],tagdist_list,taglist_num*2); |
| | | checksum = Checksum_u16(lora_sendbuffer,4*taglist_num+30); |
| | | checksum = Checksum_u16(lora_sendbuffer,4*taglist_num+ANCID_IDX); |
| | | memcpy(&lora_sendbuffer[ANCID_IDX+taglist_num*4],&checksum,2); |
| | | Radio.Send(lora_sendbuffer,ANCID_IDX+taglist_num*4+2); |
| | | bat_percent=Get_Battary(); |
| | | bat_percent=Get_Battary(); |
| | | |
| | | } |