| | |
| | | { |
| | | |
| | | } |
| | | #define HEATBEAT_UPDATE_TIME_S 3600 //心跳包一个小时上传一次 |
| | | #define HEATBEAT_UPDATE_TIME_S 600 //心跳包一个小时上传一次 |
| | | static uint16_t current_count,target_count,wg_report_id; |
| | | uint16_t heartbeat_count; |
| | | uint16_t heartbeat_count = HEATBEAT_UPDATE_TIME_S; |
| | | static uint8_t heatbeat_buffer[100]; |
| | | uint8_t diyicichongqi=1; |
| | | |
| | | void HeartbeatPoll(uint16_t wangguanid) |
| | | {//心跳包上传 ID 版本号 小组 UWB功率 LORA功率 UWB发送时间 |
| | | heartbeat_count+=sync_interval_s; |
| | | if(heartbeat_count>HEATBEAT_UPDATE_TIME_S||diyicichongqi) |
| | | { |
| | | diyicichongqi=0; |
| | | if(heartbeat_count>HEATBEAT_UPDATE_TIME_S) |
| | | { |
| | | uint16_t checksum1 = 0; |
| | | heartbeat_count = 0; |
| | | heatbeat_buffer[MSG_TYPE_IDX] = LORA_MSGTYPE_ANC_HEARTBEAT; |
| | |
| | | void LoraSendComMap(uint8_t cmd) |
| | | { |
| | | uint16_t checksum = 0; |
| | | data_length = 0x50; |
| | | data_length = 80; |
| | | lora_sendbuffer[MSG_TYPE_IDX] = LORA_MSGTYPE_READPARARESP; |
| | | lora_sendbuffer[MSG_LENGTH] = data_length+9; |
| | | lora_sendbuffer[MSG_LENGTH] = data_length+11; |
| | | memcpy(&lora_sendbuffer[SOURCE_ID_IDX],&g_com_map[DEV_ID],2); |
| | | memcpy(&lora_sendbuffer[DEST_ID_IDX],&wg_report_id,2); |
| | | lora_sendbuffer[RP_CMD_IDX] = cmd; |
| | |
| | | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); |
| | | if(flag_sync_success) //同步成功 |
| | | { uint16_t wangguanid,checksum1; |
| | | printf("同步成功\r\n"); |
| | | lora_recbuffer_len = GetLoraBufferAndLen(lora_recbuffer,&rec_sync_count);//获取LORA收到的数据和长度 |
| | | checksum1=Checksum_u16(lora_recbuffer,lora_recbuffer_len-2); |
| | | if(!memcmp(&checksum1,&lora_recbuffer[lora_recbuffer_len-2],2)) //CRC16校验是否通过 |
| | |
| | | } |
| | | }else{ |
| | | // LED_LR_ON; |
| | | printf("同步失败\r\n"); |
| | | if(sync_lost_count++>SYNCLOST_THRES) |
| | | { |
| | | sync_state = Sync_Lost; |
| | |
| | | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET); |
| | | Anchor_Vcc_Flag=0; |
| | | MX_ADC_DeInit(); |
| | | bat_volt = 3*(float)verfint_cal/AD_value[50]-0.28; |
| | | bat_volt = 3*(float)verfint_cal/AD_value[21]-0.1; |
| | | bat_percent=bat_volt*100-200; |
| | | } |
| | | #ifdef _USE_BAR_ |