From b20f94fd39346787a0e99940f0370aae0d84090a Mon Sep 17 00:00:00 2001 From: chen <15335560115@163.com> Date: 星期六, 21 六月 2025 18:18:34 +0800 Subject: [PATCH] 无感闸机基站第一版,增加存授权表和查表逻辑,将接收标签id改为4字节,但是未找到tagupdate直接回将tagnum清0的问题,导致一直抢占 --- keil/include/main/main.c | 51 +++++++++++++++++---------------------------------- 1 files changed, 17 insertions(+), 34 deletions(-) diff --git a/keil/include/main/main.c b/keil/include/main/main.c index d25232f..b59dabe 100644 --- a/keil/include/main/main.c +++ b/keil/include/main/main.c @@ -294,6 +294,9 @@ // } } +#define BIND_COUNT_NUM 50 +uint8_t bind_flag,bind_count=BIND_COUNT_NUM; +extern uint8_t find_flag; void SecondTask(void) {static uint8_t second_count; if(second_count++>60) @@ -301,6 +304,15 @@ second_count = 0; MinuteTask(); } + if(bind_flag) + { + if(bind_count--<=0) + { + bind_count=BIND_COUNT_NUM; + copy_taglist_to_flash(); + bind_flag=0; + } + } // //UWB状态检测 //if(!power_low_flag)//低供电下不需要检测重连 // { @@ -348,8 +360,10 @@ } //uart_change_check(gpio_state); } + static void sleep_timer_callback(void *dev, uint32_t time) { + if(secondtask_count++%2==0) { flag_secondtask = 1; @@ -380,16 +394,14 @@ extern uint16_t ip0,ip1,ip2,ip3,port; extern uint8_t gps_4g_flag; extern uint8_t gps_need_data_flag,gps_open_flag; + void Program_Init(void) { Usart1ParseDataCallback = UsartParseDataHandler;//需改为默认为gps处理,UsartParseDataHandler为升级处理当调试时候改为 parameter_init_anchor();//g_com_map表初始化角色默认为基站 dev_id=g_com_map[DEV_ID];//这里不太对 group_id=g_com_map[GROUP_ID];//组ID -// tag_frequency = 1000/g_com_map[COM_INTERVAL];//测距频率这个存的是测距时间 memcpy(&disoffset,&g_com_map[DIST_OFFSET],2); -// g_com_map[ALARM_DISTANCE1] = 40; -// g_com_map[ALARM_DISTANCE2] = 40; warning_distance=g_com_map[ALARM_DISTANCE1]; prewarning_distance=g_com_map[ALARM_DISTANCE2]; send_struct.warnDistence=warning_distance; @@ -419,7 +431,7 @@ port = g_com_map[TCP_PORT]; g_com_map[VERSION] = (1<<8)|0; LOG_INFO(TRACE_MODULE_APP,"设备ID: %x .\r\n",dev_id); - LOG_INFO(TRACE_MODULE_APP,"固件版本:4G-GPS定位手环 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff); + LOG_INFO(TRACE_MODULE_APP,"固件版本:MK_无感闸机 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); } @@ -525,32 +537,10 @@ // open system timer //sys_timer_open(); - // TODO 4G - Uart_Register(UART_ID_4G, UART_ID0); - Internet_Init(); - TCPClient_Init(); gpio_open(); LED_output_init();//配置彩色灯引脚 - IIC2_Init(); - Accelerometer_Init(); - PCA9555_init(); - - - //AIR780E_Reset(); adc_open(&usr_adc_cfg); - - if(!read_5v_input_pca()) - { - Set4LEDColor(BLUE,GREEN,WHITE,GREEN); - delay_ms(500); - Set4LEDColor(RED,WHITE,RED,WHITE); - delay_ms(500); - //Set4LEDColor(LEDOFF,LEDOFF,LEDOFF,LEDOFF); - } -// io_pin_mux_set(SCL_PIN, IO_FUNC0);//测试测距波形 -// gpio_pin_set_dir(SCL_PIN , GPIO_DIR_IN, 0); -// io_pull_set(SCL_PIN , IO_PULL_UP, IO_PULL_UP_LEVEL4); Program_Init(); //uart_open(UART_ID1, &test_uart_cfg); // uart1_change_from_gps_to_debug(); @@ -559,29 +549,22 @@ // Initialize low power mode power_init(); - //AIR780E_Reset(); //4G模块重启,耗时1.5秒,这个是无法同步的关键 sleep_timer_open(true, SLEEP_TIMER_MODE_RELOAD, sleep_timer_callback); - //sleep_timer_start(__MS_TO_32K_CNT(g_com_map[COM_INTERVAL]));//测试 sleep_timer_start(__MS_TO_32K_CNT(SLEEP_TIMER_NUM));//测试 - PCA9555_Set_One_Value_Output(ADC_MINIUS,0);//拉低 adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样 //board_acceleration_detection_init(move_handler); - pca_input_detection_init(pca_handler);//pca检测输入 +// pca_input_detection_init(pca_handler);//pca检测输入 //board_4GUsart_detection_init(_4gUsart_handler); Uwb_init(); OpenUWB(); while (1) { uwb_app_poll(); - Air780eTask(); if(flag_secondtask) { flag_secondtask = 0; SecondTask(); } - PowerTask(); -// IMUTask(); - UserKeyTask(); IdleTask(); #ifndef DEBUG_MODE //if(flag_sleeptimer) -- Gitblit v1.9.3