| | |
| | | #include "sx126x.h" |
| | | #include "sx126x-board.h" |
| | | #include "lora_1268.h" |
| | | //#include "lora_3029.h"" |
| | | #include "user.h" |
| | | #include "sx126x-board.h" |
| | | #include "string.h" |
| | |
| | | lora_sendbuffer[HB_LORAPOWER_IDX] = g_com_map[LORA_POWER]; |
| | | checksum = Checksum_u16(lora_sendbuffer,14); |
| | | memcpy(&lora_sendbuffer[14],&checksum,2); |
| | | // Radio.Send(lora_sendbuffer,16); |
| | | Radio.Send(lora_sendbuffer,16); |
| | | |
| | | /*****************************心跳包上传内容*************************************/ |
| | | |
| | |
| | | extern uint8_t DMA_RXBuf_BT[200]; |
| | | extern uint8_t report_ancnum; |
| | | extern uint8_t report_ancnum_bt; |
| | | uint32_t BT_SEND_flag=0; |
| | | uint32_t BT_SEND_lenth=0; |
| | | uint8_t BT_NUM=0; |
| | | extern uint16_t report_ancdist[ANC_MAX_NUM],report_ancid[ANC_MAX_NUM]; |
| | | extern uint8_t bat_percent; |
| | |
| | | extern uint32_t step_count; |
| | | uint8_t step_count_rep; |
| | | //extern u16_m f_step; |
| | | extern uint8_t uwbled,gpsled,loraled,powerled; |
| | | extern uint8_t exercise_state; |
| | | void LoraReportPoll(void) |
| | | { |
| | | // delay_ms(100); |
| | |
| | | printf("气压值:%d",intheight); |
| | | #endif |
| | | |
| | | TagListUpdate(); |
| | | // TagListUpdate(); |
| | | |
| | | LoraReportFreqPoll(); |
| | | flag_getwgresp = 0; |
| | | |
| | | SwitchLoraSettings(wg_report_freq,REPORT_CHANNEL_SF,22); |
| | | mir3da_get_step(); |
| | | // mir3da_get_step(); |
| | | if(heatbeat_count++>HEATBEAT_UPDATE_TIME && WG_Connected == wg_state) //如果心跳包到达上传时间,并且网关处于链接状态,就上传心跳包 |
| | | { |
| | | heatbeat_count = 0; |
| | |
| | | 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; |
| | | lora_sendbuffer[BAT_IDX] = bat_percent;//(uint8_t)(step_count % 256); |
| | | // lora_sendbuffer[BAT_IDX] = (uint8_t)(step_count % 256); |
| | | lora_sendbuffer[STATE_IDX] = !GET_USERKEY|stationary_flag<<1; |
| | | //GET_USERKEY这个是那个lora——busy那个引脚 |
| | | // lora_sendbuffer[STATE_IDX]=0x01; |
| | |
| | | memcpy(&lora_sendbuffer[LORA_RETRANSNUSSION_BT+1],&DMA_RXBuf_BT[0],BT_NUM*2+1); //基站ID |
| | | memcpy(&lora_sendbuffer[LORA_RETRANSNUSSION_BT+BT_NUM*2+2],&DMA_RXBuf_BT[1+BT_NUM*2],BT_NUM*2);//基站距离 |
| | | lora_sendbuffer[MSG_LENGTH] = LORA_RETRANSNUSSION_BT+4*BT_NUM+2; |
| | | |
| | | |
| | | //保留位3 |
| | | if(step_count < 0) |
| | | step_count=0; |
| | | lora_sendbuffer[STEP_COUNT] = (uint8_t)(step_count % 256); |
| | | |
| | | lora_sendbuffer[STEP_COUNT] = (uint8_t)(step_count % 256); |
| | | lora_sendbuffer[EXERCISE_STATE]=exercise_state; |
| | | lora_sendbuffer[RESERVED_POSITION]=0; |
| | | // } |
| | | // if(lora_sendbuffer[LORA_RETRANSNUSSION_BT]==0x2D) |
| | | // { |
| | | checksum = Checksum_u16(lora_sendbuffer,4*BT_NUM+4*report_ancnum+BT_ANCID_IDX+3); |
| | | memcpy(&lora_sendbuffer[LORA_RETRANSNUSSION_BT+BT_NUM*4+2],&checksum,2); |
| | | BT_SEND_flag=BT_ANCID_IDX+report_ancnum*4+BT_NUM*4+5; |
| | | BT_SEND_lenth=BT_ANCID_IDX+report_ancnum*4+BT_NUM*4+5; |
| | | |
| | | Radio.Send(lora_sendbuffer,BT_SEND_flag); |
| | | Radio.Send(lora_sendbuffer,BT_SEND_lenth); |
| | | LORA_POLL_COUNT++; |
| | | #ifdef CESHIGUJIAN |
| | | uint16_t log_info_bt[10]; |
| | | uint16_t log_info_uwb[10]; |
| | | memcpy(log_info_bt,&lora_sendbuffer[LORA_RETRANSNUSSION_BT+1],BT_NUM*2+1); |
| | | memcpy(log_info_uwb,&lora_sendbuffer[BT_ANCID_IDX+1],report_ancnum*2); |
| | | |
| | | uint16_t corrected_value =(log_info_bt[0] << 8) | (log_info_bt[0] >> 8); |
| | | uint16_t corrected_value2 =(log_info_bt[1] << 8) | (log_info_bt[1] >> 8); |
| | | LOG_INFO(TRACE_MODULE_APP,"BTNUM:%d,基站ID1: %04x ,基站ID2: %04x 运动状态:%d,步数: %d\r\n",BT_NUM,corrected_value,corrected_value2,lora_sendbuffer[EXERCISE_STATE],lora_sendbuffer[STEP_COUNT]); |
| | | LOG_INFO(TRACE_MODULE_APP,"UWBNUM:%d,基站ID1: %x,基站ID2: %x \r\n",report_ancnum,log_info_uwb[0],log_info_uwb[1]); |
| | | memset(log_info_uwb,0,10); |
| | | taglist_num==0; |
| | | #endif |
| | | // LORA_3029_SINGLE_SEND(lora_sendbuffer,ANCID_IDX+report_ancnum*4+BT_NUM*4+4,0); |
| | | // } |
| | | // else |
| | |
| | | memset(DMA_RXBuf_BT, 0,200); |
| | | memset(&lora_sendbuffer[ANCID_IDX],0,200); |
| | | //LED_TB_ON; |
| | | LORA_LED_ON; |
| | | loraled=1; |
| | | |
| | | for(uint8_t i=0;i<3;i++) |
| | | recnum[i] = 0; |
| | |
| | | //uint16_t rec_value,rec_delaytime,rx_count,datalen_offset; |
| | | |
| | | uint8_t shengji_flag,time=5; |
| | | extern uint32_t uwbled,gpsled,loraled,powerled; |
| | | //extern uint32_t uwbled,gpsled,loraled,powerled; |
| | | extern struct RxDoneMsg RxDoneParams; |
| | | |
| | | //extern uint8_t Lora_tx_ancnum; |
| | |
| | | memcpy(&lora_sendbuffer[9], &g_com_map[1], data_length); |
| | | checksum = Checksum_u16(lora_sendbuffer,11+data_length); |
| | | memcpy(&lora_sendbuffer[11+data_length],&checksum,2); |
| | | // LORA_3029_SINGLE_SEND(lora_sendbuffer,data_length+13,0); |
| | | // Radio.Send(lora_sendbuffer,data_length+13); |
| | | Radio.Send(lora_sendbuffer,data_length+13); |
| | | //++; |
| | | // Delay_Ms(100); |
| | | } |
| | |
| | | memcpy(&lora_sendbuffer[7], &g_com_map[index/2], data_length); |
| | | checksum = Checksum_u16(lora_sendbuffer,9+data_length); |
| | | memcpy(&lora_sendbuffer[9+data_length],&checksum,2); |
| | | // Radio.Send(lora_sendbuffer,data_length+11); |
| | | |
| | | // LORA_3029_SINGLE_SEND(lora_sendbuffer,data_length+11,0); |
| | | // Delay_Ms(100); |
| | | Radio.Send(lora_sendbuffer,data_length+11); |
| | | } |
| | | uint8_t t22[20],ti; |
| | | uint8_t no_yingdaflag; |
| | |
| | | else |
| | | { |
| | | Radio.Rx( 50 ); |
| | | LORA_LED_OFF; |
| | | |
| | | } |
| | | } |
| | | #define BUFFER_SIZE 255 // Define the payload size here |