invalid_characteristics

本文介绍了BW系统中处理非法字符的几种方法,包括在RSKC中进行设置、通过routine处理、直接修改PSA数据以及让用户调整原始数据等方案。

默认情况下,BW只允许以下的字符以及空格:

!"%&'()*+,-/:;<=>?_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ

除此之外的字符都会被视为非法字符。

如何解决?

1.  RSKC

     大部分情况下,在RSKC中设置为ALL_CAPITAL就是最佳的做法,但是以下数据仍然是非法的:

     只有#

     !开头

     HEX 00~1F

2. 通过routine处理非法字符

3. 直接在PSA修改数据

4. 让用户修改原始数据

 

#include "ble_service.h" #include "ble_config.h" #include "esp_log.h" #include "esp_nimble_hci.h" #include "nimble/nimble_port.h" #include "nimble/nimble_port_freertos.h" #include "host/ble_hs.h" #include "host/util/util.h" #include "services/gap/ble_svc_gap.h" #include "services/gatt/ble_svc_gatt.h" #include <string.h> #include <stdio.h> static const char *TAG = "BLE_SERVICE"; // BLE服务UUID和特征UUID static const ble_uuid128_t GATTS_SERVICE_UUID = BLE_UUID128_INIT(0x9e, 0xca, 0xdc, 0x24, 0x0e, 0xe5, 0xa9, 0xe0, 0x93, 0xf3, 0xa3, 0xb5, 0x01, 0x00, 0x40, 0x6e); static const ble_uuid128_t GATTS_CHAR_UUID_READ = BLE_UUID128_INIT(0x9e, 0xca, 0xdc, 0x24, 0x0e, 0xe5, 0xa9, 0xe0, 0x93, 0xf3, 0xa3, 0xb5, 0x02, 0x00, 0x40, 0x6e); static const ble_uuid128_t GATTS_CHAR_UUID_WRITE = BLE_UUID128_INIT(0x9e, 0xca, 0xdc, 0x24, 0x0e, 0xe5, 0xa9, 0xe0, 0x93, 0xf3, 0xa3, 0xb5, 0x03, 0x00, 0x40, 0x6e); // 全局变量 static ble_event_callback_t g_event_callback = NULL; static bool g_service_started = false; static bool g_device_connected = false; static uint16_t g_conn_handle = 0; static uint16_t g_tx_handle = 0; static uint16_t g_rx_handle = 0; // 数据缓冲区 #define BLE_DATA_BUFFER_SIZE 512 static uint8_t g_data_buffer[BLE_DATA_BUFFER_SIZE]; // 特征定义 static struct ble_gatt_chr_def characteristic_read; static struct ble_gatt_chr_def characteristic_write; // GAP事件处理 static int gap_event_handler(struct ble_gap_event *event, void *arg) { struct ble_gap_conn_desc desc; int rc; switch (event->type) { case BLE_GAP_EVENT_CONNECT: ESP_LOGI(TAG, "BLE device connected"); g_conn_handle = event->connect.conn_handle; g_device_connected = true; // 获取连接信息 rc = ble_gap_conn_find(event->connect.conn_handle, &desc); if (rc == 0) { ESP_LOGI(TAG, "Connection parameters: interval=%d, latency=%d, timeout=%d", desc.conn_itvl, desc.conn_latency, desc.supervision_timeout); } if (g_event_callback) { g_event_callback(BLE_EVENT_CONNECTED, NULL, 0); } break; case BLE_GAP_EVENT_DISCONNECT: ESP_LOGI(TAG, "BLE device disconnected, reason=%d", event->disconnect.reason); g_device_connected = false; g_conn_handle = 0; if (g_event_callback) { g_event_callback(BLE_EVENT_DISCONNECTED, NULL, 0); } // 重新开始广播 ble_service_start(); break; case BLE_GAP_EVENT_ADV_COMPLETE: ESP_LOGI(TAG, "Advertising complete"); break; case BLE_GAP_EVENT_SUBSCRIBE: ESP_LOGI(TAG, "Subscribe event: conn_handle=%d, attr_handle=%d", event->subscribe.conn_handle, event->subscribe.attr_handle); break; default: break; } return 0; } // GATT写事件处理 static int gatt_svr_chr_write(struct os_mbuf *om, uint16_t min_len, uint16_t max_len, void *dst, uint16_t *len) { uint16_t om_len; int rc; om_len = OS_MBUF_PKTLEN(om); if (om_len < min_len || om_len > max_len) { return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; } rc = ble_hs_mbuf_to_flat(om, dst, max_len, len); if (rc != 0) { return BLE_ATT_ERR_UNLIKELY; } return 0; } // 特征写回调 static int characteristic_write_cb(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) { size_t data_len = OS_MBUF_PKTLEN(ctxt->om); if (data_len > 0) { data_len = data_len > BLE_DATA_BUFFER_SIZE ? BLE_DATA_BUFFER_SIZE : data_len; memcpy(g_data_buffer, ctxt->om->om_data, data_len); g_data_buffer[data_len] = '\0'; // 处理接收到的数据 ESP_LOGI(TAG, "Received data: %.*s", (int)data_len, g_data_buffer); // 检查当前模式 if (ble_config_get_mode() == BLE_MODE_CONFIG) { // 配置模式:处理AT指令 char* received_data = (char*)g_data_buffer; if (strcmp(received_data, "+++") == 0) { ble_config_set_mode(BLE_MODE_CONFIG); if (g_event_callback) { g_event_callback(BLE_EVENT_CONFIG_MODE_ENTERED, NULL, 0); } ble_service_send_string("OK\r\n"); } else if (strncmp(received_data, "AT+", 3) == 0) { esp_err_t ret = ble_at_parse(received_data); if (ret == ESP_OK) { if (strstr(received_data, "=?")) { // 查询命令,响应由ble_at_parse处理 } else { ble_service_send_string("OK\r\n"); } } else { ble_service_send_string("ERR\r\n"); } } } else { // 透传模式:直接转发数据 if (g_event_callback) { g_event_callback(BLE_EVENT_DATA_RECEIVED, g_data_buffer, data_len); } } } } return 0; } // 特征读回调 static int characteristic_read_cb(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { // 可以在这里处理读请求 return 0; } // 服务定义 static const struct ble_gatt_svc_def gatt_svr_svcs[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &GATTS_SERVICE_UUID.u, .characteristics = (struct ble_gatt_chr_def[]) { { .uuid = &GATTS_CHAR_UUID_WRITE.u, .access_cb = characteristic_write_cb, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ, }, { .uuid = &GATTS_CHAR_UUID_READ.u, .access_cb = characteristic_read_cb, .flags = BLE_GATT_CHR_F_NOTIFY | BLE_GATT_CHR_F_READ, .val_handle = &g_tx_handle, }, { 0 } // No more characteristics in this service } }, { 0 } // No more services }; // NimBLE主机任务 static void ble_host_task(void *param) { ESP_LOGI(TAG, "BLE Host Task Started"); nimble_port_run(); nimble_port_freertos_deinit(); } // NimBLE就绪回调 static void ble_on_sync(void) { ESP_LOGI(TAG, "BLE Host Synced"); // 设置设备名称 char device_name[64] = {0}; ble_config_get_param("BLE_NAME", device_name, sizeof(device_name)); if (strlen(device_name) == 0) { strcpy(device_name, "SUPER BLE123"); // 默认名称 } // 设置GAP设备名称 ble_svc_gap_device_name_set(device_name); // 开始广播 if (g_service_started) { struct ble_gap_adv_params adv_params; struct ble_hs_adv_fields fields; // 配置广播字段 memset(&fields, 0, sizeof(fields)); fields.flags = BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP; fields.tx_pwr_lvl_is_present = 1; fields.tx_pwr_lvl = BLE_HS_ADV_TX_PWR_LVL_AUTO; fields.name = (uint8_t *)device_name; fields.name_len = strlen(device_name); fields.name_is_complete = 1; ble_gap_adv_set_fields(&fields); // 开始广播 memset(&adv_params, 0, sizeof(adv_params)); adv_params.conn_mode = BLE_GAP_CONN_MODE_UND; adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN; ble_gap_adv_start(ble_addr_type, NULL, BLE_HS_FOREVER, &adv_params, gap_event_handler, NULL); ESP_LOGI(TAG, "Advertising started with name: %s", device_name); } } // NimBLE重置回调 static void ble_on_reset(int reason) { ESP_LOGE(TAG, "BLE Host Reset, reason=%d", reason); } // 初始化BLE服务 esp_err_t ble_service_init(ble_event_callback_t callback) { if (g_service_started) { ESP_LOGW(TAG, "BLE service already initialized"); return ESP_ERR_INVALID_STATE; } g_event_callback = callback; // 初始化NimBLE esp_err_t ret = esp_nimble_hci_init(); if (ret != ESP_OK) { ESP_LOGE(TAG, "Failed to initialize NimBLE HCI: %s", esp_err_to_name(ret)); return ret; } // 初始化NimBLE主机配置 nimble_port_init(); // 设置主机同步回调 ble_hs_cfg.sync_cb = ble_on_sync; ble_hs_cfg.reset_cb = ble_on_reset; // 注册GATT服务 ret = ble_gatts_count_cfg(gatt_svr_svcs); if (ret != 0) { ESP_LOGE(TAG, "Failed to count GATT services: %d", ret); return ESP_FAIL; } ret = ble_gatts_add_svcs(gatt_svr_svcs); if (ret != 0) { ESP_LOGE(TAG, "Failed to add GATT services: %d", ret); return ESP_FAIL; } // 启动NimBLE主机任务 nimble_port_freertos_init(ble_host_task); ESP_LOGI(TAG, "BLE service initialized successfully with NimBLE"); return ESP_OK; } // 启动BLE服务 esp_err_t ble_service_start(void) { if (g_service_started) { ESP_LOGW(TAG, "BLE service already started"); return ESP_ERR_INVALID_STATE; } g_service_started = true; // 如果已经同步,直接开始广播 if (ble_hs_synced()) { struct ble_gap_adv_params adv_params; // 设置设备名称 char device_name[64] = {0}; ble_config_get_param("BLE_NAME", device_name, sizeof(device_name)); if (strlen(device_name) == 0) { strcpy(device_name, "SUPER BLE123"); } ble_svc_gap_device_name_set(device_name); // 开始广播 memset(&adv_params, 0, sizeof(adv_params)); adv_params.conn_mode = BLE_GAP_CONN_MODE_UND; adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN; ble_gap_adv_start(ble_addr_type, NULL, BLE_HS_FOREVER, &adv_params, gap_event_handler, NULL); ESP_LOGI(TAG, "Advertising started with name: %s", device_name); } ESP_LOGI(TAG, "BLE service started"); return ESP_OK; } // 停止BLE服务 esp_err_t ble_service_stop(void) { if (!g_service_started) { return ESP_ERR_INVALID_STATE; } // 停止广播 ble_gap_adv_stop(); // 断开所有连接 if (g_device_connected) { ble_gap_terminate(g_conn_handle, BLE_ERR_REM_USER_CONN_TERM); } g_service_started = false; g_device_connected = false; ESP_LOGI(TAG, "BLE service stopped"); return ESP_OK; } // 发送数据 esp_err_t ble_service_send_data(const uint8_t* data, size_t length) { if (!g_service_started) { ESP_LOGE(TAG, "BLE service not started"); return ESP_ERR_INVALID_STATE; } if (!data || length == 0) { return ESP_ERR_INVALID_ARG; } if (!g_device_connected) { ESP_LOGW(TAG, "No BLE connection"); return ESP_ERR_INVALID_STATE; } if (g_tx_handle == 0) { ESP_LOGE(TAG, "Characteristic handle not ready"); return ESP_ERR_INVALID_STATE; } // 使用通知方式发送数据 int rc = ble_gatts_notify_custom(g_conn_handle, g_tx_handle, length, data); if (rc != 0) { ESP_LOGE(TAG, "Failed to send data: %d", rc); return ESP_FAIL; } ESP_LOGI(TAG, "Data sent successfully: %.*s", (int)length, data); return ESP_OK; } // 发送字符串 esp_err_t ble_service_send_string(const char* str) { if (!str) { return ESP_ERR_INVALID_ARG; } return ble_service_send_data((const uint8_t*)str, strlen(str)); } // 发送AT响应 esp_err_t ble_service_send_at_response(const char* response) { return ble_service_send_string(response); } // 获取连接状态 bool ble_service_is_connected(void) { return g_device_connected; } // 获取BLE配置指针 ble_config_t* ble_service_get_config(void) { return NULL; }
10-24
eekBar: drawCircleAndIconInternal, needAnimation:false, upScale: 1.0, icon: TELE, fadeIn: false, fadeOut: false, upscale: 1.0, iconText: 0.6×, pivotX: 648.0 10-24 17:27:43.080405 10559 10559 V OCAM_ZoomSeekBar: getZoomValue, IconType: TELE zoomPointMap: {ULTRA_WIDE=0.6, WIDE=1.0, DUAL=2.0, TELE=3.5, MORE=7.0} 10-24 17:27:43.080415 10559 10559 V OCAM_ZoomSeekBar: drawTextSpecialStyle, mCurrentDisplayUnitText:× 10-24 17:27:43.080429 10559 10559 D OCAM_ZoomSeekBar: keepLatestDisplayText, type:TELE, text: 3.5, isSelected:false 10-24 17:27:43.080441 10559 10559 V OCAM_ZoomSeekBar: getClickPointType, index: 0, zoomPointMap: {ULTRA_WIDE=0.6, WIDE=1.0, DUAL=2.0, TELE=3.5, MORE=7.0}, ret:1 10-24 17:27:43.080451 10559 10559 V OCAM_ZoomSeekBar: getClickPointType, index: 0, zoomPointMap: {ULTRA_WIDE=0.6, WIDE=1.0, DUAL=2.0, TELE=3.5, MORE=7.0}, ret:1 10-24 17:27:43.080460 10559 10559 V OCAM_ZoomSeekBar: getClickPointType, index: 0, zoomPointMap: {ULTRA_WIDE=0.6, WIDE=1.0, DUAL=2.0, TELE=3.5, MORE=7.0}, ret:1 10-24 17:27:43.080473 10559 10559 V OCAM_ZoomSeekBar: drawCircleAndIconInternal, needAnimation:false, upScale: 1.0, icon: MORE, fadeIn: false, fadeOut: false, upscale: 1.0, iconText: 0.6×, pivotX: 756.0 10-24 17:27:43.080480 10559 10559 V OCAM_ZoomSeekBar: getZoomValue, IconType: MORE zoomPointMap: {ULTRA_WIDE=0.6, WIDE=1.0, DUAL=2.0, TELE=3.5, MORE=7.0} 10-24 17:27:43.080489 10559 10559 V OCAM_ZoomSeekBar: drawTextSpecialStyle, mCurrentDisplayUnitText:× 10-24 17:27:43.080502 10559 10559 D OCAM_ZoomSeekBar: keepLatestDisplayText, type:MORE, text: 7, isSelected:false 10-24 17:27:43.087307 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.087445 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.087464 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.098683 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.098777 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.098794 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.109382 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.109611 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.109632 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.120569 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.120682 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.120701 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.131623 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.131795 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.131874 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.142442 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.142491 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.142506 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.144469 2676 6395 I Camera3-Status: dumpActiveComponents: component 12 (Stream 26) is active 10-24 17:27:43.144633 2676 6395 I Camera3-Status: dumpActiveComponents: component 13 (Stream 33) is active 10-24 17:27:43.144668 2676 6395 E Camera3-Device: Camera 0: waitUntilDrainedLocked: Error waiting for HAL to drain: Connection timed out (-110) 10-24 17:27:43.154529 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.154618 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.154636 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.157666 1926 28524 I resolv : res_nsend: used send_dg 0 terrno: 110 10-24 17:27:43.165001 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.165261 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.165274 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.175409 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.175529 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.175598 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.186132 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.186169 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.186176 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.197258 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.197295 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.197302 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.208141 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.208179 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.208214 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.219029 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.219051 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.219055 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.230096 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.230132 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.230144 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.240470 2152 25128 E QC2V4l2Codec: [v4lavcE_41] RGBA8888_UBWC is not a supported pixel format! 10-24 17:27:43.240639 2152 25128 W QC2V4l2Codec: [v4lavcE_41] handleInputs: failed due to buffer incompatibility, or invalid_state[0] dropping input 10-24 17:27:43.240724 2152 25128 E QC2V4l2Codec: [v4lavcE_41] handleCodecMessage: failed to queue input buffer 10-24 17:27:43.241226 2676 6395 D CameraTraces: Process trace saved. Use dumpsys media.camera to view. 10-24 17:27:43.242505 10559 11160 E CameraCaptureSession: Session 4: Failed to create capture session; configuration failed 10-24 17:27:43.242795 10559 11161 W om.oplus.camera: Long monitor contention with owner CameraControlThread (11160) at void android.hardware.camera2.impl.CameraDeviceImpl.waitUntilIdle()(CameraDeviceImpl.java:1799) waiters=0 in void android.hardware.camera2.impl.CameraDeviceImpl$6.run() for 5.098s 10-24 17:27:43.242929 10559 11160 E CameraUnit, ProducerImpl: onSessionConfigureFail, error result: [error code: 10002, error info: stream surface error] 10-24 17:27:43.243071 10559 11160 E OCAM_OneCameraImpl: onCameraPreviewError, error: PREVIEW_CONFIG_FAILED 10-24 17:27:43.243117 10559 11160 E OCAM_AutoLogHelper: tryCatchPreviewExceptionLog , reason: PREVIEW_CONFIG_FAILED, triggerReason: -1 10-24 17:27:43.243189 10559 11161 I Quality : MonitorInfo:com.oplus.camera,run,CameraDeviceImpl.java_299,5099 10-24 17:27:43.243249 10559 11160 E OCAM_AutoLogHelper: tryCatchPreviewExceptionLog inner, reason: PREVIEW_CONFIG_FAILED 10-24 17:27:43.243390 10559 10643 I Quality : MonitorInfo:com.oplus.camera,onDeviceError,CameraDeviceImpl.java_2286,98 10-24 17:27:43.243608 10559 11160 I CameraUnit, Camera2StateMachineImpl: setDeviceState, cameraName: rear_sat, mDeviceState: SESSION_CREATING -> SESSION_CONFIGURED_FAILED 10-24 17:27:43.243941 10559 11161 D CameraUnit, StateCallback: onConfigureFailed,android.hardware.camera2.impl.CameraCaptureSessionImpl@fc22b11 10-24 17:27:43.243999 10559 11161 E CameraUnit, ProducerImpl: onSessionConfigureFail, error result: [error code: 10002, error info: stream surface error] 10-24 17:27:43.244035 10559 11161 E OCAM_OneCameraImpl: onCameraPreviewError, error: PREVIEW_CONFIG_FAILED 10-24 17:27:43.244055 10559 11161 E OCAM_AutoLogHelper: tryCatchPreviewExceptionLog , reason: PREVIEW_CONFIG_FAILED, triggerReason: -1 10-24 17:27:43.244091 10559 11161 E OCAM_AutoLogHelper: tryCatchPreviewExceptionLog inner, reason: PREVIEW_CONFIG_FAILED 10-24 17:27:43.244145 10559 11161 I CameraUnit, Camera2StateMachineImpl: setDeviceState, cameraName: rear_sat, mDeviceState: SESSION_CONFIGURED_FAILED -> SESSION_CONFIGURED_FAILED 10-24 17:27:43.244275 10559 11161 D CameraUnit, StateCallback: onError,android.hardware.camera2.impl.CameraDeviceImpl@34dce5, cameraUnit version: 6.106.63 10-24 17:27:43.244303 10559 25616 D OCAM_FeatureConflictDecision: onDataChanged: mmkv://com.oplus.camera/com.oplus.camera_preferences?class_type=java.lang.Long#preview_exception 10-24 17:27:43.244333 10559 11161 E CameraUnit, Camera2StateMachineImpl: onError, ops, camera have some error, error code: 4 10-24 17:27:43.244362 10559 25616 D OCAM_FeatureConflictDecision: getFeatureConflictMap, getFeatureConflictMap: featureKey: preview_exception, featureValueType: class java.lang.Long, has none featureInfo! 10-24 17:27:43.244394 10559 25616 D OCAM_ZoomPresenter: onDataChanged, prefKey: preview_exception 10-24 17:27:43.244445 10559 25616 V OCAM_CameraCore: onDataChanged, dataKey: preview_exception, this: com.oplus.camera.CameraManager@6bbe82d, mActivity: com.oplus.camera.Camera@e979857 10-24 17:27:43.244681 10559 25616 E OCAM_AutoLogManager: try to catch. 10-24 17:27:43.244858 10559 25616 E OCAM_AutoLogManager: prepare capture. 10-24 17:27:43.245025 10559 25616 E OCAM_AutoLogHelper: tryCatchPreviewExceptionLog onCatch, request: Request{requestReason='PREVIEW_CONFIG_FAILED', mLux=-1, mExceptionID=268505089, mMemoryAvailable=-1.0, mRunningMemoryAvailable=-1.0, mTemperature=-1.0, mCaptureModeName='common', mTimeStamp=1761298063244'}, result: CatchResult{mResultCode='failed', mDetailInfo='Interval limit denied, checkIntervalLimit: 604800000', mRequest=null} 10-24 17:27:43.245336 10559 25616 E OCAM_AutoLogManager: try to catch. 10-24 17:27:43.245417 10559 25616 D OCAM_LogCoreManager: sendException mOlcServiceInterface: com.oplus.olc.IOplusLogCore$Stub$Proxy@d850db0 10-24 17:27:43.245700 10559 25237 E OCAM_OneCameraImpl: onSessionConfigureFail, errorCode: 10002, errorInfo: stream surface error 10-24 17:27:43.245738 10559 25237 E OCAM_PreviewProcessor: onSessionConfigureFailed 10-24 17:27:43.245794 10559 25237 I OCAM_PreviewProcessor: changePreviewState, CREATING_CAPTURE_SESSION -> INIT 10-24 17:27:43.245831 10559 25237 V OCAM_OppoCamera_TRACE: traceBeginSection, msg: PreviewProcessor.raisePreviewControlEvent 10-24 17:27:43.245955 10559 11161 E CameraUnit, ProducerImpl: onCameraError, error result: [error code: 4, error info: camera device error, at: com.oplus.ocs.camera.producer.device.Camera2StateMachineImpl$1.onError(Camera2StateMachineImpl.java:128)] 10-24 17:27:43.246148 10559 25237 V OCAM_k1_BaseMode: getPictureSize, sizeList: [4096x3072, 3840x2160, 3840x1644, 3840x1608, 3280x1856, 3264x2448, 2880x2160, 2640x1200, 2624x1968, 2580x1080, 2560x1440, 2520x1080, 2344x1080, 2304x1728, 2304x1060, 2304x1048, 2160x1080, 2136x1200, 1920x1440, 1920x1280, 1920x1080, 4096x2304, 4096x1888, 4000x1818, 4000x3000, 4000x2250, 3840x2560, 3456x3456, 3136x2352, 3072x3072, 3000x3000, 2976x2232, 2944x2208, 2560x1920, 1984x1488, 1856x1392, 2016x1512, 1728x1296, 1680x1260, 1600x1200, 480x360, 480x270, 480x218, 360x360] 10-24 17:27:43.246159 10559 11161 D CameraUnit, StatisticsManager: report, mAppId: 20009, mEventId: abnormal_display, params: {pack_name=com.oplus.camera, rear_front=rear, abnormal_preview=1, camera_id=0, enter_time=1735660858753, preview_start_time=1761298042708} 10-24 17:27:43.246210 10559 11160 E CameraUnit, Camera2StateMachineImpl: handleMessage, create capture session failed. android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): waitUntilIdle:1776: Camera 0: Error waiting to drain: Connection timed out (-110) at android.hardware.camera2.utils.ExceptionUtils.throwAsPublicException(ExceptionUtils.java:75) at android.hardware.camera2.impl.ICameraDeviceUserWrapper.waitUntilIdle(ICameraDeviceUserWrapper.java:199) at android.hardware.camera2.impl.CameraDeviceImpl.waitUntilIdle(CameraDeviceImpl.java:1798) at android.hardware.camera2.impl.CameraDeviceImpl.configureStreamsChecked(CameraDeviceImpl.java:732) at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSessionInternal(CameraDeviceImpl.java:1053) at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:981) at com.oplus.ocs.camera.producer.device.Camera2Impl.createNewSession(Camera2Impl.java:3136) at com.oplus.ocs.camera.producer.device.Camera2StateMachineImpl$StateMachineHandler.handleMessage(Camera2StateMachineImpl.java:413) at android.os.Handler.dispatchMessage(Handler.java:115) at android.os.Looper.loopOnce(Looper.java:298) at android.os.Looper.loop(Looper.java:408) at android.os.HandlerThread.run(HandlerThread.java:85) at com.oplus.ocs.camera.common.util.CameraHandlerThread.run(CameraHandlerThread.java:36) Caused by: android.os.ServiceSpecificException: waitUntilIdle:1776: Camera 0: Error waiting to drain: Connection timed out (-110) (code 10) at android.os.Parcel.createExceptionOrNull(Parcel.java:3384) at android.os.Parcel.createException(Parcel.java:3354) at android.os.Parcel.readException(Parcel.java:3337) at android.os.Parcel.readException(Parcel.java:3279) at android.hardware.camera2.ICameraDeviceUser$Stub$Proxy.waitUntilIdle(ICameraDeviceUser.java:984) at android.hardware.camera2.impl.ICameraDeviceUserWrapper.waitUntilIdle(ICameraDeviceUserWrapper.java:197) ... 11 more 10-24 17:27:43.246318 10559 25237 V OCAM_SizeUtils: getOptimalSizeByRatio, size: 4096x2304, targetRatio: 1.7777777777777777 precise true 10-24 17:27:43.246358 10559 25237 I OCAM_SeamlessUIControl: onPreviewStateChanged, previewState : PREVIEW_STATE_INIT 10-24 17:27:43.246379 10559 11160 D CameraUnit, Camera2StateMachineImpl: closeCameraDecision这又是什么情况,在刚刚的日志上面打印的
最新发布
10-31
#include "ble_service.h" #include "ble_config.h" // 假设你自己实现了该配置模块 #include "esp_log.h" #include "esp_nimble_hci.h" #include "nimble/nimble_port.h" #include "nimble/nimble_port_freertos.h" #include "host/ble_hs.h" #include "host/util/util.h" #include "services/gap/ble_svc_gap.h" #include "services/gatt/ble_svc_gatt.h" #include <string.h> #include <stdio.h> // 如果你没有实现 ble_at_parse,请注释掉相关逻辑或替换为 dummy 函数 extern esp_err_t ble_at_parse(const char *at_cmd); // 声明外部 AT 解析函数 static const char *TAG = "BLE_SERVICE"; // ------------------------------- // UUID 定义:Nordic UART Service (NUS) 风格 // ------------------------------- // 主服务 UUID: 6E400001-B5A3-F393-E0A9-E50E24DCCA9E static const ble_uuid128_t gatt_svr_svc_uuid = BLE_UUID128_INIT( 0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x01, 0x00, 0x40, 0x6E); // 写特征 UUID: 6E400002-B5A3-F393-E0A9-E50E24DCCA9E static const ble_uuid128_t gatt_svr_chr_write_uuid = BLE_UUID128_INIT( 0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x02, 0x00, 0x40, 0x6E); // 读特征 UUID: 6E400003-B5A3-F393-E0A9-E50E24DCCA9E static const ble_uuid128_t gatt_svr_chr_read_uuid = BLE_UUID128_INIT( 0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x03, 0x00, 0x40, 0x6E); // ------------------------------- // 全局变量 // ------------------------------- static ble_event_callback_t g_event_callback = NULL; static bool g_service_started = false; static bool g_device_connected = false; static uint16_t g_conn_handle = 0; // ⚠️ 关键:必须用指针接收 handle 分配! static uint16_t g_rx_val_handle; // 接收写入的 Characteristic Value Handle static uint16_t g_tx_val_handle; // 发送通知的 Characteristic Value Handle #define BLE_DATA_BUFFER_SIZE 512 static uint8_t g_data_buffer[BLE_DATA_BUFFER_SIZE]; // ------------------------------- // GATT 访问回调函数 // ------------------------------- /** * @brief 处理客户端对 WRITE 特征的写操作 */ static int characteristic_write_cb(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { if (ctxt->op != BLE_GATT_ACCESS_OP_WRITE_CHR) { return BLE_ATT_ERR_UNLIKELY; } size_t data_len = OS_MBUF_PKTLEN(ctxt->om); if (data_len == 0 || data_len >= BLE_DATA_BUFFER_SIZE) { return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; } // 将 mbuf 数据拷贝到缓冲区 int rc = ble_hs_mbuf_to_flat(ctxt->om, g_data_buffer, BLE_DATA_BUFFER_SIZE, &data_len); if (rc != 0) { ESP_LOGE(TAG, "Failed to flatten mbuf: %d", rc); return BLE_ATT_ERR_UNLIKELY; } g_data_buffer[data_len] = '\0'; ESP_LOGI(TAG, "Received write: %.*s", (int)data_len, g_data_buffer); // 根据当前模式处理 if (ble_config_get_mode() == BLE_MODE_CONFIG) { if (strcmp((char*)g_data_buffer, "+++") == 0) { ble_config_set_mode(BLE_MODE_CONFIG); if (g_event_callback) { g_event_callback(BLE_EVENT_CONFIG_MODE_ENTERED, NULL, 0); } ble_service_send_string("OK\r\n"); } else if (strncmp((char*)g_data_buffer, "AT+", 3) == 0) { esp_err_t ret = ble_at_parse((char*)g_data_buffer); ble_service_send_string(ret == ESP_OK ? "OK\r\n" : "ERR\r\n"); } } else { if (g_event_callback) { g_event_callback(BLE_EVENT_DATA_RECEIVED, g_data_buffer, data_len); } } return 0; } /** * @brief 处理 READ 特征的读请求(可选) */ static int characteristic_read_cb(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { // 示例:返回静态字符串 const char *response = "Hello from BLE"; int len = strlen(response); os_mbuf_append(ctxt->om, response, len); return 0; } // ------------------------------- // GATT 服务定义 // ------------------------------- static const struct ble_gatt_svc_def gatt_svr_svcs[] = { { .type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = &gatt_svr_svc_uuid.u, .characteristics = (struct ble_gatt_chr_def[]) { [0] = { .uuid = &gatt_svr_chr_write_uuid.u, .access_cb = characteristic_write_cb, .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ, }, [1] = { .uuid = &gatt_svr_chr_read_uuid.u, .access_cb = characteristic_read_cb, .flags = BLE_GATT_CHR_F_NOTIFY | BLE_GATT_CHR_F_READ, .val_handle = &g_tx_val_handle, // ✅ 自动填充 handle }, [2] = { 0 } // End of characteristics } }, { 0 // End of services } }; // ------------------------------- // GAP 事件处理器 // ------------------------------- static int gap_event_handler(struct ble_gap_event *event, void *arg) { switch (event->type) { case BLE_GAP_EVENT_CONNECT: ESP_LOGI(TAG, "BLE connected"); g_conn_handle = event->connect.conn_handle; g_device_connected = true; struct ble_gap_conn_desc desc; int rc = ble_gap_conn_find(g_conn_handle, &desc); if (rc == 0) { ESP_LOGI(TAG, "Conn interval=%dms latency=%d timeout=%dms", desc.conn_itvl * 1.25, desc.conn_latency, desc.supervision_timeout * 10); } if (g_event_callback) { g_event_callback(BLE_EVENT_CONNECTED, NULL, 0); } break; case BLE_GAP_EVENT_DISCONNECT: ESP_LOGI(TAG, "Disconnected, reason=%d", event->disconnect.reason); g_device_connected = false; g_conn_handle = 0; g_tx_val_handle = 0; // Reset handle if (g_event_callback) { g_event_callback(BLE_EVENT_DISCONNECTED, NULL, 0); } // 可选择重新广播 if (g_service_started) { ble_service_start(); } break; case BLE_GAP_EVENT_ADV_COMPLETE: ESP_LOGI(TAG, "Advertising stopped"); break; case BLE_GAP_EVENT_SUBSCRIBE: ESP_LOGI(TAG, "Client subscribed to notify: val_handle=%d new_value=%d", g_tx_val_handle, event->subscribe.cur_notify); break; default: break; } return 0; } // ------------------------------- // NimBLE 同步与重置回调 // ------------------------------- static void ble_on_sync(void) { ESP_LOGI(TAG, "BLE Host synced"); // 获取设备名 char device_name[64] = {0}; ble_config_get_param("BLE_NAME", device_name, sizeof(device_name)); if (strlen(device_name) == 0) { strcpy(device_name, "SUPER BLE123"); } ble_svc_gap_device_name_set(device_name); // 开始广播(如果已启用) if (g_service_started) { struct ble_gap_adv_params adv_params = {0}; struct ble_hs_adv_fields fields = {0}; fields.flags = BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP; fields.tx_pwr_lvl_is_present = 1; fields.tx_pwr_lvl = BLE_HS_ADV_TX_PWR_LVL_AUTO; fields.name = (uint8_t *)device_name; fields.name_len = strlen(device_name); fields.name_is_complete = 1; ble_gap_adv_set_fields(&fields); adv_params.conn_mode = BLE_GAP_CONN_MODE_UND; adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN; int rc = ble_gap_adv_start(BLE_OWN_ADDR_TYPE_PUBLIC, NULL, BLE_HS_FOREVER, &adv_params, gap_event_handler, NULL); if (rc != 0) { ESP_LOGE(TAG, "Failed to start advertising: %d", rc); } else { ESP_LOGI(TAG, "Advertising started: %s", device_name); } } } static void ble_on_reset(int reason) { ESP_LOGE(TAG, "Resetting BLE stack, reason=%d", reason); } // ------------------------------- // 主机任务(由 nimble_port_freertos_init 调用) // ------------------------------- static void ble_host_task(void *param) { ESP_LOGI(TAG, "BLE Host Task Running"); nimble_port_run(); // 永久阻塞运行 nimble_port_freertos_deinit(); vTaskDelete(NULL); } // ------------------------------- // API 实现 // ------------------------------- esp_err_t ble_service_init(ble_event_callback_t callback) { if (g_service_started) { ESP_LOGW(TAG, "Already initialized"); return ESP_ERR_INVALID_STATE; } g_event_callback = callback; // 初始化 HCI 层 esp_err_t ret = esp_nimble_hci_and_controller_init(); if (ret != ESP_OK) { ESP_LOGE(TAG, "HCI init failed: %s", esp_err_to_name(ret)); return ret; } // 初始化 NimBLE 主机 nimble_port_init(); // 设置回调 ble_hs_cfg.sync_cb = ble_on_sync; ble_hs_cfg.reset_cb = ble_on_reset; // 注册 GATT 服务 int rc = ble_gatts_count_cfg(gatt_svr_svcs); if (rc != 0) { ESP_LOGE(TAG, "Service count failed: %d", rc); goto err; } rc = ble_gatts_add_svcs(gatt_svr_svcs); if (rc != 0) { ESP_LOGE(TAG, "Add services failed: %d", rc); goto err; } // 启动主机任务 nimble_port_freertos_init(ble_host_task); ESP_LOGI(TAG, "BLE service initialized"); return ESP_OK; err: esp_nimble_hci_and_controller_deinit(); return ESP_FAIL; } esp_err_t ble_service_start(void) { if (g_service_started) { ESP_LOGW(TAG, "Already started"); return ESP_ERR_INVALID_STATE; } g_service_started = true; if (ble_hs_is_enabled()) { ble_on_sync(); // 手动触发同步流程 } return ESP_OK; } esp_err_t ble_service_stop(void) { if (!g_service_started) { return ESP_ERR_INVALID_STATE; } ble_gap_adv_stop(); if (g_device_connected) { ble_gap_terminate(g_conn_handle, BLE_ERR_REM_USER_CONN_TERM); } g_service_started = false; g_device_connected = false; ESP_LOGI(TAG, "BLE service stopped"); return ESP_OK; } esp_err_t ble_service_send_data(const uint8_t *data, size_t length) { if (!g_service_started || !g_device_connected) { ESP_LOGW(TAG, "Not connected or not started"); return ESP_ERR_INVALID_STATE; } if (!data || length == 0) { return ESP_ERR_INVALID_ARG; } if (g_tx_val_handle == 0) { ESP_LOGE(TAG, "TX handle not assigned yet!"); return ESP_ERR_INVALID_STATE; } int rc = ble_gattc_notify_custom(g_conn_handle, g_tx_val_handle, length, (uint8_t *)data); if (rc != 0) { ESP_LOGE(TAG, "Notify failed: %d", rc); return ESP_FAIL; } ESP_LOGD(TAG, "Sent %zu bytes via notify", length); return ESP_OK; } esp_err_t ble_service_send_string(const char *str) { if (!str) return ESP_ERR_INVALID_ARG; return ble_service_send_data((const uint8_t *)str, strlen(str)); } esp_err_t ble_service_send_at_response(const char *response) { return ble_service_send_string(response); } bool ble_service_is_connected(void) { return g_device_connected; } ble_config_t* ble_service_get_config(void) { // 假设你有一个全局配置对象,否则请实现它 extern ble_config_t g_ble_config; return &g_ble_config; } In file included from C:/Espressif/frameworks/esp-idf-v5.3.1/components/bt/host/nimble/nimble/porting/nimble/include/modlog/modlog.h:30, from C:/Espressif/frameworks/esp-idf-v5.3.1/components/bt/host/nimble/nimble/nimble/host/include/host/ble_hs_log.h:36, from C:/Espressif/frameworks/esp-idf-v5.3.1/components/bt/host/nimble/nimble/nimble/host/include/host/ble_hs.h:38: E:/espdemo/LED/components/BLE/ble_service.c: In function 'gap_event_handler': C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:290:27: error: format '%d' expects argument of type 'int', but argument 6 has type 'double' [-Werror=format=] 290 | #define LOG_COLOR(COLOR) "\033[0;" COLOR "m" | ^~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:293:27: note: in expansion of macro 'LOG_COLOR' 293 | #define LOG_COLOR_E LOG_COLOR(LOG_COLOR_RED) | ^~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:307:37: note: in expansion of macro 'LOG_COLOR_E' 307 | #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n" | ^~~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:435:86: note: in expansion of macro 'LOG_FORMAT' 435 | if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:463:41: note: in expansion of macro 'ESP_LOG_LEVEL' 463 | if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:367:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 367 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ E:/espdemo/LED/components/BLE/ble_service.c:165:17: note: in expansion of macro 'ESP_LOGI' 165 | ESP_LOGI(TAG, "Conn interval=%dms latency=%d timeout=%dms", | ^~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:290:27: error: format '%d' expects argument of type 'int', but argument 6 has type 'double' [-Werror=format=] 290 | #define LOG_COLOR(COLOR) "\033[0;" COLOR "m" | ^~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:294:27: note: in expansion of macro 'LOG_COLOR' 294 | #define LOG_COLOR_W LOG_COLOR(LOG_COLOR_BROWN) | ^~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:307:37: note: in expansion of macro 'LOG_COLOR_W' 307 | #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n" | ^~~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:436:86: note: in expansion of macro 'LOG_FORMAT' 436 | else if (level==ESP_LOG_WARN ) { esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:463:41: note: in expansion of macro 'ESP_LOG_LEVEL' 463 | if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:367:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 367 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ E:/espdemo/LED/components/BLE/ble_service.c:165:17: note: in expansion of macro 'ESP_LOGI' 165 | ESP_LOGI(TAG, "Conn interval=%dms latency=%d timeout=%dms", | ^~~~~~~~ E:/espdemo/LED/components/BLE/ble_service.c:168:1: error: format '%d' expects argument of type 'int', but argument 6 has type 'double' [-Werror=format=] 168 | desc.supervision_timeout * 10); | ^ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:307:59: note: in definition of macro 'LOG_FORMAT' 307 | #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n" | ^~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:463:41: note: in expansion of macro 'ESP_LOG_LEVEL' 463 | if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:367:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 367 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ E:/espdemo/LED/components/BLE/ble_service.c:165:17: note: in expansion of macro 'ESP_LOGI' 165 | ESP_LOGI(TAG, "Conn interval=%dms latency=%d timeout=%dms", | ^~~~~~~~ E:/espdemo/LED/components/BLE/ble_service.c:168:1: error: format '%d' expects argument of type 'int', but argument 6 has type 'double' [-Werror=format=] 168 | desc.supervision_timeout * 10); | ^ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:307:59: note: in definition of macro 'LOG_FORMAT' 307 | #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n" | ^~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:463:41: note: in expansion of macro 'ESP_LOG_LEVEL' 463 | if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:367:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 367 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ E:/espdemo/LED/components/BLE/ble_service.c:165:17: note: in expansion of macro 'ESP_LOGI' 165 | ESP_LOGI(TAG, "Conn interval=%dms latency=%d timeout=%dms", | ^~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:290:27: error: format '%d' expects argument of type 'int', but argument 6 has type 'double' [-Werror=format=] 290 | #define LOG_COLOR(COLOR) "\033[0;" COLOR "m" | ^~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:295:27: note: in expansion of macro 'LOG_COLOR' 295 | #define LOG_COLOR_I LOG_COLOR(LOG_COLOR_GREEN) | ^~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:307:37: note: in expansion of macro 'LOG_COLOR_I' 307 | #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n" | ^~~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:439:86: note: in expansion of macro 'LOG_FORMAT' 439 | else { esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:463:41: note: in expansion of macro 'ESP_LOG_LEVEL' 463 | if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/log/include/esp_log.h:367:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 367 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ E:/espdemo/LED/components/BLE/ble_service.c:165:17: note: in expansion of macro 'ESP_LOGI' 165 | ESP_LOGI(TAG, "Conn interval=%dms latency=%d timeout=%dms", | ^~~~~~~~ E:/espdemo/LED/components/BLE/ble_service.c: In function 'ble_on_sync': E:/espdemo/LED/components/BLE/ble_service.c:243:36: error: 'BLE_OWN_ADDR_TYPE_PUBLIC' undeclared (first use in this function); did you mean 'BLE_OWN_ADDR_PUBLIC'? 243 | int rc = ble_gap_adv_start(BLE_OWN_ADDR_TYPE_PUBLIC, NULL, BLE_HS_FOREVER, | ^~~~~~~~~~~~~~~~~~~~~~~~ | BLE_OWN_ADDR_PUBLIC E:/espdemo/LED/components/BLE/ble_service.c:243:36: note: each undeclared identifier is reported only once for each function it appears in E:/espdemo/LED/components/BLE/ble_service.c: In function 'ble_service_init': E:/espdemo/LED/components/BLE/ble_service.c:286:21: error: implicit declaration of function 'esp_nimble_hci_and_controller_init' [-Werror=implicit-function-declaration] 286 | esp_err_t ret = esp_nimble_hci_and_controller_init(); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ E:/espdemo/LED/components/BLE/ble_service.c:319:5: error: implicit declaration of function 'esp_nimble_hci_and_controller_deinit' [-Werror=implicit-function-declaration] 319 | esp_nimble_hci_and_controller_deinit(); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ E:/espdemo/LED/components/BLE/ble_service.c: In function 'ble_service_send_data': E:/espdemo/LED/components/BLE/ble_service.c:372:70: warning: passing argument 3 of 'ble_gattc_notify_custom' makes pointer from integer without a cast [-Wint-conversion] 372 | int rc = ble_gattc_notify_custom(g_conn_handle, g_tx_val_handle, length, (uint8_t *)data); | ^~~~~~ | | | size_t {aka unsigned int} In file included from C:/Espressif/frameworks/esp-idf-v5.3.1/components/bt/host/nimble/nimble/nimble/host/include/host/ble_hs.h:34: C:/Espressif/frameworks/esp-idf-v5.3.1/components/bt/host/nimble/nimble/nimble/host/include/host/ble_gatt.h:858:45: note: expected 'struct os_mbuf *' but argument is of type 'size_t' {aka 'unsigned int'} 858 | struct os_mbuf *om); | ~~~~~~~~~~~~~~~~^~ E:/espdemo/LED/components/BLE/ble_service.c:372:14: error: too many arguments to function 'ble_gattc_notify_custom' 372 | int rc = ble_gattc_notify_custom(g_conn_handle, g_tx_val_handle, length, (uint8_t *)data); | ^~~~~~~~~~~~~~~~~~~~~~~ C:/Espressif/frameworks/esp-idf-v5.3.1/components/bt/host/nimble/nimble/nimble/host/include/host/ble_gatt.h:857:5: note: declared here 857 | int ble_gattc_notify_custom(uint16_t conn_handle, uint16_t att_handle, | ^~~~~~~~~~~~~~~~~~~~~~~ E:/espdemo/LED/components/BLE/ble_service.c: At top level: E:/espdemo/LED/components/BLE/ble_service.c:50:17:
10-24
/*---------------------------------------------------------------------- | AP4_AvcFrameParser::ParseHrd +---------------------------------------------------------------------*/ AP4_Result AP4_AvcFrameParser::ParseHrd(AP4_BitReader& bits, AP4_HrdParameterSet& hrd) { hrd.cpb_cnt_minus1 = ReadGolomb(bits); if (hrd.cpb_cnt_minus1 >= 32) { DBG_PRINTF_1("hrd.cpb_cnt_minus1[%d] >= 32\n", hrd.cpb_cnt_minus1); return AP4_ERROR_INVALID_FORMAT; } hrd.bit_rate_scale = bits.ReadBits(4); hrd.cpb_size_scale = bits.ReadBits(4); for (unsigned int i = 0; i <= hrd.cpb_cnt_minus1; i++) { hrd.bit_rate_value_minus1[i] = ReadGolomb(bits); hrd.cpb_size_value_minus1[i] = ReadGolomb(bits); hrd.cbr_flag[i] = bits.ReadBit(); } hrd.initial_cpb_removal_delay_length_minus1 = bits.ReadBits(5); hrd.cpb_removal_delay_length_minus1 = bits.ReadBits(5); hrd.dpb_output_delay_length_minus1 = bits.ReadBits(5); hrd.time_offset_length = bits.ReadBits(5); return AP4_SUCCESS; } /*---------------------------------------------------------------------- | AP4_AvcFrameParser::ParseVui +---------------------------------------------------------------------*/ AP4_Result AP4_AvcFrameParser::ParseVui(AP4_BitReader& bits, AP4_VuiParameterSet& vui) { vui.aspect_ratio_info_present_flag = bits.ReadBit(); if (vui.aspect_ratio_info_present_flag) { vui.aspect_ratio_idc = bits.ReadBits(8); // Appendix E. Table E-1 Meaning of sample aspect ratio indicator if (vui.aspect_ratio_idc == 255/*Extended_SAR*/) { vui.sar_width = bits.ReadBits(16); vui.sar_height = bits.ReadBits(16); } } vui.overscan_info_present_flag = bits.ReadBit(); if (vui.overscan_info_present_flag) { vui.overscan_appropriate_flag = bits.ReadBit(); } vui.video_signal_type_present_flag = bits.ReadBit(); if (vui.video_signal_type_present_flag) { vui.video_format = bits.ReadBits(3); vui.video_full_range_flag = bits.ReadBit(); vui.colour_description_present_flag = bits.ReadBit(); if (vui.colour_description_present_flag) { vui.colour_primaries = bits.ReadBits(8); vui.transfer_characteristics = bits.ReadBits(8); vui.matrix_coefficients = bits.ReadBits(8); } } vui.chroma_loc_info_present_flag = bits.ReadBit(); if (vui.chroma_loc_info_present_flag) { vui.chroma_sample_loc_type_top_field = ReadGolomb(bits); vui.chroma_sample_loc_type_bottom_field = ReadGolomb(bits); } vui.timing_info_present_flag = bits.ReadBit(); if (vui.timing_info_present_flag) { vui.num_units_in_tick = bits.ReadBits(32); vui.time_scale = bits.ReadBits(32); vui.fixed_frame_rate_flag = bits.ReadBit(); } vui.nal_hrd_parameters_present_flag = bits.ReadBit(); if (vui.nal_hrd_parameters_present_flag) { AP4_Result result = ParseHrd(bits, vui.nal_hrd); if (AP4_FAILED(result)) { return result; } } vui.vcl_hrd_parameters_present_flag = bits.ReadBit(); if (vui.vcl_hrd_parameters_present_flag) { AP4_Result result = ParseHrd(bits, vui.vcl_hrd); if (AP4_FAILED(result)) { return result; } } if (vui.nal_hrd_parameters_present_flag || vui.vcl_hrd_parameters_present_flag) { vui.low_delay_hrd_flag = bits.ReadBit(); } vui.pic_struct_present_flag = bits.ReadBit(); vui.bitstream_restriction_flag = bits.ReadBit(); if (vui.bitstream_restriction_flag) { vui.motion_vectors_over_pic_boundaries_flag = bits.ReadBit(); vui.max_bytes_per_pic_denom = ReadGolomb(bits); vui.max_bits_per_mb_denom = ReadGolomb(bits); vui.log2_max_mv_length_horizontal = ReadGolomb(bits); vui.log2_max_mv_length_vertical = ReadGolomb(bits); vui.num_reorder_frames = ReadGolomb(bits); vui.max_dec_frame_buffering = ReadGolomb(bits); } return AP4_SUCCESS; } 注释上述代码
09-24
/*---------------------------------------------------------------------- | AP4_HevcVuiParameterSet::AP4_HevcVuiParameterSet +---------------------------------------------------------------------*/ AP4_Result AP4_HevcVuiParameterSet::Parse(AP4_BitReader& bits) { aspect_ratio_info_present_flag = bits.ReadBit(); if (aspect_ratio_info_present_flag) { aspect_ratio_idc = bits.ReadBits(8); // Appendix E. Table E-1 Meaning of sample aspect ratio indicator if (aspect_ratio_idc == 255/*Extended_SAR*/) { sar_width = bits.ReadBits(16); sar_height = bits.ReadBits(16); } } overscan_info_present_flag = bits.ReadBit(); if (overscan_info_present_flag) { overscan_appropriate_flag = bits.ReadBit(); } video_signal_type_present_flag = bits.ReadBit(); if (video_signal_type_present_flag) { video_format = bits.ReadBits(3); video_full_range_flag = bits.ReadBit(); colour_description_present_flag = bits.ReadBit(); if (colour_description_present_flag) { colour_primaries = bits.ReadBits(8); transfer_characteristics = bits.ReadBits(8); matrix_coefficients = bits.ReadBits(8); } } chroma_loc_info_present_flag = bits.ReadBit(); if (chroma_loc_info_present_flag) { chroma_sample_loc_type_top_field = ReadGolomb(bits); chroma_sample_loc_type_bottom_field = ReadGolomb(bits); } neutral_chroma_indication_flag = bits.ReadBit(); field_seq_flag = bits.ReadBit(); frame_field_info_present_flag = bits.ReadBit(); default_display_window_flag = bits.ReadBit(); if (default_display_window_flag) { def_disp_win_left_offset = ReadGolomb(bits); def_disp_win_right_offset = ReadGolomb(bits); def_disp_win_top_offset = ReadGolomb(bits); def_disp_win_bottom_offset = ReadGolomb(bits); } timing_info_present_flag = bits.ReadBit(); if (timing_info_present_flag) { num_units_in_tick = bits.ReadBits(32); time_scale = bits.ReadBits(32); vui_poc_proportional_to_timing_flag = bits.ReadBit(); if (vui_poc_proportional_to_timing_flag) { vui_num_ticks_poc_diff_one_minus1 = ReadGolomb(bits); } } return AP4_SUCCESS; } /*---------------------------------------------------------------------- | AP4_HevcPictureParameterSet::AP4_HevcPictureParameterSet +---------------------------------------------------------------------*/ AP4_HevcPictureParameterSet::AP4_HevcPictureParameterSet() : pps_pic_parameter_set_id(0), pps_seq_parameter_set_id(0), dependent_slice_segments_enabled_flag(0), output_flag_present_flag(0), num_extra_slice_header_bits(0), sign_data_hiding_enabled_flag(0), cabac_init_present_flag(0), num_ref_idx_l0_default_active_minus1(0), num_ref_idx_l1_default_active_minus1(0), init_qp_minus26(0), constrained_intra_pred_flag(0), transform_skip_enabled_flag(0), cu_qp_delta_enabled_flag(0), diff_cu_qp_delta_depth(0), pps_cb_qp_offset(0), pps_cr_qp_offset(0), pps_slice_chroma_qp_offsets_present_flag(0), weighted_pred_flag(0), weighted_bipred_flag(0), transquant_bypass_enabled_flag(0), tiles_enabled_flag(0), entropy_coding_sync_enabled_flag(0), num_tile_columns_minus1(0), num_tile_rows_minus1(0), uniform_spacing_flag(1), loop_filter_across_tiles_enabled_flag(0), pps_loop_filter_across_slices_enabled_flag(0), deblocking_filter_control_present_flag(0), deblocking_filter_override_enabled_flag(0), pps_deblocking_filter_disabled_flag(0), pps_beta_offset_div2(0), pps_tc_offset_div2(0), pps_scaling_list_data_present_flag(0), lists_modification_present_flag(0), log2_parallel_merge_level_minus2(0), slice_segment_header_extension_present_flag(0) { } /*---------------------------------------------------------------------- | AP4_HevcPictureParameterSet::Parse +---------------------------------------------------------------------*/ AP4_Result AP4_HevcPictureParameterSet::Parse(const unsigned char* data, unsigned int data_size) { raw_bytes.SetData(data, data_size); AP4_DataBuffer unescaped(data, data_size); AP4_NalParser::Unescape(unescaped); AP4_BitReader bits(unescaped.GetData(), unescaped.GetDataSize()); bits.SkipBits(16); // NAL Unit Header pps_pic_parameter_set_id = ReadGolomb(bits); if (pps_pic_parameter_set_id > AP4_HEVC_PPS_MAX_ID) { DBG_PRINTF_2("pps_pic_parameter_set_id[%d] > AP4_HEVC_PPS_MAX_ID[%d]\n", pps_pic_parameter_set_id, AP4_HEVC_PPS_MAX_ID); return AP4_ERROR_INVALID_FORMAT; } pps_seq_parameter_set_id = ReadGolomb(bits); if (pps_seq_parameter_set_id > AP4_HEVC_SPS_MAX_ID) { DBG_PRINTF_2("pps_seq_parameter_set_id[%d] > AP4_HEVC_SPS_MAX_ID[%d]\n", pps_seq_parameter_set_id, AP4_HEVC_SPS_MAX_ID); return AP4_ERROR_INVALID_FORMAT; } dependent_slice_segments_enabled_flag = bits.ReadBit(); output_flag_present_flag = bits.ReadBit(); num_extra_slice_header_bits = bits.ReadBits(3); sign_data_hiding_enabled_flag = bits.ReadBit(); cabac_init_present_flag = bits.ReadBit(); num_ref_idx_l0_default_active_minus1 = ReadGolomb(bits); num_ref_idx_l1_default_active_minus1 = ReadGolomb(bits); init_qp_minus26 = SignedGolomb(ReadGolomb(bits)); constrained_intra_pred_flag = bits.ReadBit(); transform_skip_enabled_flag = bits.ReadBit(); cu_qp_delta_enabled_flag = bits.ReadBit(); if (cu_qp_delta_enabled_flag) { diff_cu_qp_delta_depth = ReadGolomb(bits); } pps_cb_qp_offset = SignedGolomb(ReadGolomb(bits)); pps_cr_qp_offset = SignedGolomb(ReadGolomb(bits)); pps_slice_chroma_qp_offsets_present_flag = bits.ReadBit(); weighted_pred_flag = bits.ReadBit(); weighted_bipred_flag = bits.ReadBit(); transquant_bypass_enabled_flag = bits.ReadBit(); tiles_enabled_flag = bits.ReadBit(); entropy_coding_sync_enabled_flag = bits.ReadBit(); if (tiles_enabled_flag) { num_tile_columns_minus1 = ReadGolomb(bits); num_tile_rows_minus1 = ReadGolomb(bits); uniform_spacing_flag = bits.ReadBit(); if (!uniform_spacing_flag) { for (unsigned int i=0; i<num_tile_columns_minus1; i++) { ReadGolomb(bits); // column_width_minus1[i] } for (unsigned int i = 0; i < num_tile_rows_minus1; i++) { ReadGolomb(bits); // row_height_minus1[i] } } loop_filter_across_tiles_enabled_flag = bits.ReadBit(); } pps_loop_filter_across_slices_enabled_flag = bits.ReadBit(); deblocking_filter_control_present_flag = bits.ReadBit(); if (deblocking_filter_control_present_flag) { deblocking_filter_override_enabled_flag = bits.ReadBit(); pps_deblocking_filter_disabled_flag = bits.ReadBit(); if (!pps_deblocking_filter_disabled_flag) { pps_beta_offset_div2 = SignedGolomb(ReadGolomb(bits)); pps_tc_offset_div2 = SignedGolomb(ReadGolomb(bits)); } } pps_scaling_list_data_present_flag = bits.ReadBit(); if (pps_scaling_list_data_present_flag) { scaling_list_data(bits); } lists_modification_present_flag = bits.ReadBit(); log2_parallel_merge_level_minus2 = ReadGolomb(bits); slice_segment_header_extension_present_flag = bits.ReadBit(); return AP4_SUCCESS; } 详细注释上述代码
09-25
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值