| | |
| | | #include "dw_app_anchor.h" |
| | | #include "HIDO_TypeDef.h" |
| | | #include "PCA9555.h" |
| | | #include "mk_misc.h" |
| | | /********************************************结构体**************************************************************/ |
| | | typedef enum |
| | | { |
| | |
| | | uint8_t BT_NUM=0; |
| | | extern uint16_t report_ancdist[ANC_MAX_NUM],report_ancid[ANC_MAX_NUM]; |
| | | extern uint8_t bat_percent; |
| | | extern uint16_t REV_RX_NUM; |
| | | extern uint16_t REV_POLL_NUM; |
| | | extern uint16_t REPLY_POLL_NUM; |
| | | uint16_t num[3]={0,0,0}; |
| | | extern uint8_t stationary_flag; |
| | | void LoraReportPoll(void) |
| | | { |
| | | // delay_ms(100); |
| | |
| | | printf("气压值:%d",intheight); |
| | | #endif |
| | | |
| | | TagListUpdate(); |
| | | // TagListUpdate(); |
| | | |
| | | LoraReportFreqPoll(); |
| | | flag_getwgresp = 0; |
| | |
| | | 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; |
| | | BT_NUM=DMA_RXBuf_BT[0]; |
| | | // lora_sendbuffer[MSG_TYPE_IDX] = LORA_MSGTYPE_TAGMSGTOWG; |
| | | lora_sendbuffer[MSG_TYPE_IDX] = LORA_MSGTYPE_TAGMSGTOWG_BT; |
| | | lora_sendbuffer[MSG_LENGTH] = 4*report_ancnum+4*BT_NUM+ANCID_IDX+3; |
| | | #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; |
| | | lora_sendbuffer[STATE_IDX] = !GET_USERKEY|stationary_flag<<1; |
| | | //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); |
| | |
| | | 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); |
| | | memcpy(&lora_sendbuffer[BAR_HEIGHT_IDX],&intheight,2); |
| | | lora_sendbuffer[BT_ANCID_IDX] = report_ancnum; |
| | | memcpy(&lora_sendbuffer[BT_ANCID_IDX+1],report_ancid,report_ancnum*2); |
| | | memcpy(&lora_sendbuffer[BT_ANCID_IDX+report_ancnum*2+1],report_ancdist,report_ancnum*2); |
| | | uint8_t LORA_RETRANSNUSSION_BT=0; |
| | | BT_NUM=DMA_RXBuf_BT[0]; |
| | | if(0<BT_NUM&&BT_NUM<11) |
| | | { |
| | | lora_sendbuffer[MSG_TYPE_IDX] = LORA_MSGTYPE_TAGMSGTOWG_BT; |
| | | LORA_RETRANSNUSSION_BT=ANCID_IDX+report_ancnum*4; |
| | | //LORA_RETRANSNUSSION_BT report_ancnum_bt |
| | | // |
| | | // num[0]=REV_RX_NUM; |
| | | // num[1]=REV_POLL_NUM; |
| | | // num[2]=REPLY_POLL_NUM; |
| | | LORA_RETRANSNUSSION_BT=BT_ANCID_IDX+report_ancnum*4+1; |
| | | lora_sendbuffer[LORA_RETRANSNUSSION_BT] = 0x2D; //蓝牙上传标识符 |
| | | |
| | | 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] = 4*report_ancnum+4*BT_NUM+ANCID_IDX+2; |
| | | } |
| | | if(lora_sendbuffer[LORA_RETRANSNUSSION_BT]==0x2D) |
| | | { |
| | | checksum = Checksum_u16(lora_sendbuffer,4*BT_NUM+4*report_ancnum+ANCID_IDX+2); |
| | | memcpy(&lora_sendbuffer[ANCID_IDX+BT_NUM*4+report_ancnum*4+2],&checksum,2); |
| | | BT_SEND_flag++; |
| | | Radio.Send(lora_sendbuffer,ANCID_IDX+report_ancnum*4+BT_NUM*4+4); |
| | | lora_sendbuffer[MSG_LENGTH] = LORA_RETRANSNUSSION_BT+4*BT_NUM+2; |
| | | // } |
| | | // 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; |
| | | Radio.Send(lora_sendbuffer,BT_SEND_flag); |
| | | // LORA_3029_SINGLE_SEND(lora_sendbuffer,ANCID_IDX+report_ancnum*4+BT_NUM*4+4,0); |
| | | } |
| | | else |
| | | { |
| | | checksum = Checksum_u16(lora_sendbuffer,4*report_ancnum+ANCID_IDX); |
| | | memcpy(&lora_sendbuffer[ANCID_IDX+report_ancnum*4],&checksum,2); |
| | | Radio.Send(lora_sendbuffer,ANCID_IDX+report_ancnum*4+BT_NUM*4+2); |
| | | } |
| | | // } |
| | | // else |
| | | // { |
| | | // checksum = Checksum_u16(lora_sendbuffer,4*report_ancnum+ANCID_IDX); |
| | | // memcpy(&lora_sendbuffer[ANCID_IDX+report_ancnum*4],&checksum,2); |
| | | // Radio.Send(lora_sendbuffer,ANCID_IDX+report_ancnum*4+BT_NUM*4+2); |
| | | // } |
| | | |
| | | |
| | | // LORA_3029_SINGLE_SEND(lora_sendbuffer,ANCID_IDX+report_ancnum*4+BT_NUM*4+4,0); |
| | |
| | | |
| | | void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) |
| | | { |
| | | |
| | | |
| | | uint16_t checksum1; |
| | | uint16_t checksum1; |
| | | BufferSize = size; |
| | | memcpy( RX_Buffer, payload, BufferSize ); |
| | | RssiValue = rssi; |
| | |
| | | { |
| | | rec_secdelay = 0; |
| | | } |
| | | sleep_time_count = rec_delaytime - delaytime-datalen_offset; |
| | | while(sleep_time_count>=1000) |
| | | sleep_time_count-=1000; |
| | | sleep_timer_start(sleep_time_count); |
| | | |
| | | sleep_time_count =(__MS_TO_32K_CNT(rec_delaytime)/10)- delaytime-datalen_offset; |
| | | while(sleep_time_count>=32768) |
| | | { |
| | | sleep_time_count-=32768; |
| | | } |
| | | // sleep_timer_start(sleep_time_count); |
| | | break; |
| | | case WGRSP_RWTAG_READ: |
| | | no_rx_flag = 1; |