feat: BLE 新增 RS485 地址/波特率读写 + 空闲关蓝牙超时 + 功能码细分
- 新增 CMD_DBN_RW_UART_BAUD (0x31): 读写 RS485 波特率、485 地址、空闲关蓝牙超时 - storage.h: 新增 flash 地址 ADDR_BT_Close_TIMEOUT_Offset(0x10)、Addr_RS485_Baud_Offset(0x11,3B)、Addr_RS485_ID_Offset(0x14) - 功能码细分: g_function_mode bit0→fm_700bs_disable(0=700BS/1=Modbus), bit1→fm_radar_input_disable(0=光耦/1=复位) - factory_dev 出厂默认: RS485 ID=1, 波特率=9600, 蓝牙超时=0 - para_store_init 上电从 flash 恢复所有新增配置
This commit is contained in:
@@ -33,7 +33,16 @@
|
||||
|
||||
uint8_t g_flag_bt_state = 0; // 0 蓝牙没有连接,1 有蓝牙连接
|
||||
uint8_t g_function_mode = 0;
|
||||
uint8_t g_fm_700bs_disable = 0; //0: 700bs protocol; 1 Modbus protocol
|
||||
uint8_t g_fm_radar_input_disable = 0; //0: radar input enable; 1 reset
|
||||
uint32_t g_sys_freq = 0;
|
||||
uint8_t g_storage_uart_num = 0;
|
||||
uint32_t g_storage_uart_baud = 19200;//9600;
|
||||
uint8_t g_max_counter_bt_min = 0;
|
||||
uint32_t g_max_counter_bt_timeout = 0; //BT_DISABLE_IDLE_TIMEOUT * 60 * 1000; // ms unit
|
||||
|
||||
uint8_t g_rs485_id = 0;
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
* IO 宏定义 -- DLD154Pro 硬件资源
|
||||
@@ -277,6 +286,11 @@ void factory_dev(void){
|
||||
i = 4;
|
||||
memcpy(&rBuf[i], &g_loop_cng_unit.sensitvity, 7);
|
||||
i += 7;
|
||||
rBuf[Addr_RS485_ID_Offset] = 1;
|
||||
rBuf[Addr_RS485_Baud_Offset] = RS_BAUD_DEFAULT & 0xFF;
|
||||
rBuf[Addr_RS485_Baud_Offset + 1] = (RS_BAUD_DEFAULT >> 8) & 0xFF;
|
||||
rBuf[Addr_RS485_Baud_Offset + 2] = (RS_BAUD_DEFAULT >> 16) & 0xFF;
|
||||
rBuf[ADDR_BT_Close_TIMEOUT_Offset] = 0;
|
||||
|
||||
i = Addr_Loop_Sens_List_Offset;
|
||||
if(g_loop_sens_list.total > MAX_LOOP_SENS_AMOUNT)
|
||||
@@ -313,11 +327,19 @@ void para_store_init(void)
|
||||
memcpy(&g_loop_cng_unit, &rBuf[4], sizeof(g_loop_cng_unit));
|
||||
memcpy(&g_loop_sens_list, &rBuf[Addr_Loop_Sens_List_Offset], sizeof(g_loop_sens_list));
|
||||
|
||||
g_rs485_id = rBuf[Addr_RS485_ID_Offset];
|
||||
g_storage_uart_baud = rBuf[Addr_RS485_Baud_Offset] | (rBuf[Addr_RS485_Baud_Offset + 1] << 8) | (rBuf[Addr_RS485_Baud_Offset + 2] << 16);
|
||||
g_max_counter_bt_min = rBuf[ADDR_BT_Close_TIMEOUT_Offset]; // unit: minute
|
||||
g_max_counter_bt_timeout = g_max_counter_bt_min * 60 * 1000; // unit: ms
|
||||
|
||||
|
||||
g_loop_out_delay = g_loop_cng_unit.delay_time * 2; // 定时器以 50ms 为单位, 延时以100ms为单位
|
||||
g_hold_time = g_loop_cng_unit.exist_mode * 20 * 5; //50ms/per, period: 5s
|
||||
g_safe_max_cnt = g_loop_cng_unit.loopSafe_Timeout * 10 * (1000 / 50);
|
||||
g_freq_level = g_loop_cng_unit.loopFreq_Level - 1;
|
||||
g_function_mode = g_loop_cng_unit.direction_mode >> 4;
|
||||
g_fm_700bs_disable = g_function_mode & 0x01;
|
||||
g_fm_radar_input_disable = (g_function_mode >> 1) & 0x01;
|
||||
g_freq_sens = (g_loop_cng_unit.sensitvity > 0) ? (g_loop_cng_unit.sensitvity - 1) : 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
Reference in New Issue
Block a user