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:
@@ -429,6 +429,8 @@ static void unpack_pkg_set_cjq_param(uint8_t *pkg, uint8_t len)
|
||||
g_loop_cng_unit.direction_mode = pkg[i++];
|
||||
|
||||
g_function_mode = (g_loop_cng_unit.direction_mode >> 4) & 0x0F;
|
||||
g_fm_700bs_disable = g_function_mode & 0x01;
|
||||
g_fm_radar_input_disable = (g_function_mode >> 1) & 0x01;
|
||||
|
||||
g_hold_time = g_loop_cng_unit.exist_mode * 20 * 5;
|
||||
g_freq_sens = (g_loop_cng_unit.sensitvity > 0) ? (g_loop_cng_unit.sensitvity - 1) : 0;
|
||||
@@ -637,6 +639,42 @@ void manage_dbn_ble_default(uint8_t *pkg, uint8_t len)
|
||||
set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, i);
|
||||
// PRINT("\nGet_Cjq_param\n");
|
||||
} break;
|
||||
case CMD_DBN_RW_UART_BAUD:{ // 读写波特率
|
||||
uint8_t _rw = pkg[4];
|
||||
uint32_t _baud = 0;
|
||||
i = 0;
|
||||
tmp_ble_buf[i++] = _rw;
|
||||
tmp_ble_buf[i++] = 0x0; //status
|
||||
|
||||
if(_rw == 0){// read baud
|
||||
tmp_ble_buf[i++] = g_max_counter_bt_min; // 表示空闲蓝牙超时关闭时间
|
||||
tmp_ble_buf[i++] = (uint8_t)g_storage_uart_baud; //1 为485串口,g_storage_uart_baud;2 为TTL串口g_storage_uart_baud_2
|
||||
tmp_ble_buf[i++] = (uint8_t)(g_storage_uart_baud >> 8);
|
||||
tmp_ble_buf[i++] = (uint8_t)(g_storage_uart_baud >> 16);
|
||||
tmp_ble_buf[i++] = g_rs485_id;
|
||||
tmp_ble_buf[i++] = 0;
|
||||
tmp_ble_buf[i++] = 0;
|
||||
tmp_ble_buf[i++] = 0;
|
||||
// 4BYte Reserved
|
||||
|
||||
}
|
||||
else { // write baud
|
||||
g_max_counter_bt_min = pkg[5];
|
||||
g_storage_uart_baud = pkg[6];
|
||||
g_storage_uart_baud |= (uint16_t)(pkg[7] << 8) & 0xFF00;
|
||||
g_storage_uart_baud |= (uint32_t)(pkg[8] << 16) & 0xFF0000;
|
||||
g_rs485_id = pkg[9];
|
||||
|
||||
tmp_ble_buf[i++] = g_max_counter_bt_min;
|
||||
tmp_ble_buf[i++] = (uint8_t)g_storage_uart_baud;
|
||||
tmp_ble_buf[i++] = (uint8_t)(g_storage_uart_baud >> 8);
|
||||
tmp_ble_buf[i++] = (uint8_t)(g_storage_uart_baud >> 16);
|
||||
tmp_ble_buf[i++] = g_rs485_id; tmp_ble_buf[i++] = 0x00; tmp_ble_buf[i++] = 0x00; tmp_ble_buf[i++] = 0x00; // 3BYte Reserved
|
||||
|
||||
write_cfg_to_store(ADDR_BT_Close_TIMEOUT_Offset, &tmp_ble_buf[2], 5);
|
||||
}
|
||||
set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, i);
|
||||
} break;
|
||||
// case CMD_DBN_LOOP_SAMPLE_PARAM:{
|
||||
// // 获取/设置 地感采样参数
|
||||
//// PRINT("SAMPLE_CNG: %02X\n", pkg[4]);
|
||||
|
||||
Reference in New Issue
Block a user