| | |
| | | #include "HIDO_Timer.h" |
| | | #include "TCPClient.h" |
| | | |
| | | #define DEBUG_MODE |
| | | //#define DEBUG_MODE |
| | | extern int simple_main(void); |
| | | extern int temp_main(void); |
| | | #define TEST_UART_POLL_MODE 0 |
| | |
| | | //} |
| | | extern uint8_t gps_uwb_flag; |
| | | uint8_t TCP_reconnect_timer,flag_TCP_reconnectting = 1,flag_alam_state = 0; |
| | | uint8_t gps_enable_flag,motor_open_air_flag,moter_open_uwb_flag; |
| | | uint8_t gps_enable_flag,motor_open_air_flag,moter_open_uwb_flag,flag_fenli_alarm = 0,fenli_alarm_count;; |
| | | int need_open_gps_count; |
| | | void MotorPoll(void) |
| | | { |
| | |
| | | } else { //绑定状态下 |
| | | if(anchordata_num==1) { |
| | | if(distance<g_com_map[ALARM_DISTANCE1]) { //小于预警距离 |
| | | fenli_alarm_count = 0; |
| | | if(flag_fenli_alarm) |
| | | { |
| | | flag_fenli_alarm = 0; |
| | | fenli_alarm_count = 0; |
| | | _4GAlarmUpload(2); |
| | | } |
| | | } |
| | | } |
| | | if(distance>g_com_map[ALARM_DISTANCE1]||anchordata_num==0) |
| | | { |
| | | if(fenli_alarm_count++>20) |
| | | { |
| | | if(!flag_fenli_alarm) |
| | | { |
| | | flag_fenli_alarm = 1; |
| | | _4GAlarmUpload(1); |
| | | } |
| | | } |
| | | } |
| | | if(distance<g_com_map[ALARM_DISTANCE1]) { //小于预警距离 |
| | | if(flag_alam_state) |
| | | { |
| | | flag_alam_state = 0; |
| | | _4GAlarmUpload(2); |
| | | } |
| | | |
| | | } |
| | | |
| | | need_open_gps_count=0; |
| | | moter_open_uwb_flag=0;//关闭震动 |
| | | gps_uwb_flag=0;//关闭GPS |
| | |
| | | if(!flag_alam_state) |
| | | { |
| | | flag_alam_state = 1; |
| | | _4GAlarmUpload(1); |
| | | } |
| | | gps_uwb_flag=1;//开启gps测距流程 |
| | | need_open_gps_count=0; |
| | |
| | | if(!flag_alam_state) |
| | | { |
| | | flag_alam_state = 1; |
| | | _4GAlarmUpload(1); |
| | | } |
| | | gps_uwb_flag=1;//开启gps测距流程 |
| | | need_open_gps_count=0; |
| | | } |
| | | } |
| | | } else if(anchordata_num==0) { |
| | | |
| | | } |
| | | if(anchordata_num==0) { |
| | | if(!flag_alam_state) |
| | | { |
| | | flag_alam_state = 1; |
| | | _4GAlarmUpload(1); |
| | | } |
| | | distance = -1; |
| | | distance = 0x1ffff; |
| | | gps_uwb_flag=1;//开启gps测距流程 |
| | | moter_open_uwb_flag=1;//开启震动 |
| | | need_open_gps_count=0; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | void MinuteTask(void) |
| | | { |
| | | adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样 |
| | |
| | | } |
| | | //UWB更新列表 |
| | | TagListUpdate(); |
| | | //GPS_Poll(); |
| | | gps_power_state=1;//测试gps长开 |
| | | GPS_Poll(); |
| | | //gps_power_state=1;//测试gps长开 |
| | | //UWB状态检测 |
| | | |
| | | if(IfTCPConnected()) |
| | |
| | | nomove_count++; |
| | | } |
| | | uint8_t tt=1; |
| | | uint8_t flag_sleeptimer,flag_secondtask,secondtask_count; |
| | | uint8_t flag_sleeptimer,flag_secondtask,secondtask_count,log_4g_enable_flag; |
| | | |
| | | static void sleep_timer_callback(void *dev, uint32_t time) |
| | | { |
| | | IO_control_init(); |
| | |
| | | } |
| | | extern uint16_t ip0,ip1,ip2,ip3,port; |
| | | extern uint8_t gps_4g_flag; |
| | | extern uint8_t gps_need_data_flag; |
| | | void Program_Init(void) |
| | | { |
| | | Usart1ParseDataCallback = UsartParseDataHandler;//需改为默认为gps处理,UsartParseDataHandler为升级处理当调试时候改为 |
| | |
| | | if(g_com_map[SEND_4G_SECOND]<60) |
| | | g_com_map[SEND_4G_SECOND]=60; |
| | | g_com_map[MODBUS_MODE] = 0; |
| | | log_4g_enable_flag=g_com_map[LOG_4G_ENABLE]; |
| | | ip0 = (g_com_map[TCP_IP_0]>>12&0xf)*1000+(g_com_map[TCP_IP_0]>>8&0xf)*100+(g_com_map[TCP_IP_0]>>4&0xf)*10+(g_com_map[TCP_IP_0]&0xf); |
| | | ip1 = (g_com_map[TCP_IP_1]>>12&0xf)*1000+(g_com_map[TCP_IP_1]>>8&0xf)*100+(g_com_map[TCP_IP_1]>>4&0xf)*10+(g_com_map[TCP_IP_1]&0xf); |
| | | ip2 = (g_com_map[TCP_IP_2]>>12&0xf)*1000+(g_com_map[TCP_IP_2]>>8&0xf)*100+(g_com_map[TCP_IP_2]>>4&0xf)*10+(g_com_map[TCP_IP_2]&0xf); |
| | | ip3 = (g_com_map[TCP_IP_3]>>12&0xf)*1000+(g_com_map[TCP_IP_3]>>8&0xf)*100+(g_com_map[TCP_IP_3]>>4&0xf)*10+(g_com_map[TCP_IP_3]&0xf); |
| | | port = g_com_map[TCP_PORT]; |
| | | g_com_map[VERSION] = (1<<8)|4; |
| | | g_com_map[VERSION] = (1<<8)|9; |
| | | LOG_INFO(TRACE_MODULE_APP,"设备ID: %x .\r\n",dev_id); |
| | | LOG_INFO(TRACE_MODULE_APP,"固件版本:UWB-4G车载手环 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff); |
| | | LOG_INFO(TRACE_MODULE_APP,"服务器地址: %d.%d.%d.%d:%d.\r\n",ip0,ip1,ip2,ip3,port); |
| | |
| | | { |
| | | if(flag_TCP_reconnectting||IfTCPConnected()) |
| | | { |
| | | |
| | | // LOG_INFO(TRACE_MODULE_APP, "处理4G任务\r\n"); |
| | | air780_led_on(); |
| | | if(flag_4guart_needinit) |
| | |
| | | //} |
| | | #ifndef DEBUG_MODE |
| | | //if(flag_sleeptimer) |
| | | if(!gpio_pin_get_val(INPUT_5V_Pin)&&((IfTCPConnected()&&Socket_IsSendQueueEmpty(0))||!flag_TCP_reconnectting&&!IfTCPConnected())) //进入休眠条件(与关系,全满足才进):1.没有5V输入 2 TCP已连接时发送队列为空||TCP无连接时不在重连状态。 |
| | | if(!gps_need_data_flag&&!gpio_pin_get_val(INPUT_5V_Pin)&&((IfTCPConnected()&&Socket_IsSendQueueEmpty(0))||!flag_TCP_reconnectting&&!IfTCPConnected())) //进入休眠条件(与关系,全满足才进):1.没有5V输入 2 TCP已连接时发送队列为空||TCP无连接时不在重连状态。 |
| | | { |
| | | if(!flag_4guart_needinit) |
| | | { |