From 555490c1dfd26737473249d5b7eddd20dab59890 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Thu, 11 Jul 2024 11:42:20 +0800 Subject: [PATCH] =?utf8?q?ai=E5=BD=95=E9=9F=B3=E5=8F=91=E9=80=81=E4=BF=AE?= =?utf8?q?=E6=94=B9=E5=A2=9E=E5=8A=A0=E5=BB=B6=E6=97=B6=EF=BC=8C=E5=8F=8A?= =?utf8?q?=E9=87=8D=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../fd230app/nativeui/goal/src/goalmodel.cpp | 2 +- .../service/ble_service/bleservice/bleEvent.c | 25 +++++++++++-------- .../ble_service/bleservice/bleService.c | 17 +++++++++---- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp index a8776dc20..8d3f95a70 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp @@ -90,7 +90,7 @@ namespace OHOS float distancedata = (float)get_distance_data() / 1000.0; memset((void *)distancenewstr, 0, 20); - sprintf_s(distancenewstr, 20, "%f", distancedata); + sprintf_s(distancenewstr, 20, "%0.1f", distancedata); return distancenewstr; } diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index ddf095f38..48fc3c9b2 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -290,7 +290,7 @@ void sendDataNow(uint8_t *buf,uint16_t len) } } -void send_big_data(uint8_t flag, char *data, int datalen, int total, uint32_t Packet_id, uint32_t packet_total, uint8_t type_id, uint8_t type) +void send_big_data(uint8_t flag, char *data, uint16_t datalen, uint32_t total, uint32_t Packet_id, uint32_t packet_total, uint8_t type_id, uint8_t type) { // 动态分配内存空间,防止堆栈溢出 uint8_t *buf = ym_malloc(17 + datalen + 1); @@ -2034,7 +2034,8 @@ uint8_t binCheck_AI(uint8_t *buf,uint8_t *check,uint16_t len)//json 格式解析 } else if(buf[offset]==0) { - offset++; + printf("AI 解析失败\r\n"); + offset++; } } @@ -3902,11 +3903,19 @@ static void GetPasswordCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota } } -#define AI_RECORD_PATH "/user/userdata/AiRecording/AIAudio.pcm" +#ifdef AI_USE_PCM +#define AI_RECORD_PCM_PATH "/user/userdata/AiRecording/AIAudio.pcm" +#else +#define AI_RECORD_SBC_PATH "/user/userdata/AiRecording/AIAudio.sbc" +#endif bool get_AI_PATH_and_size(char *path,uint32_t *size) { - memcpy((void*)path,AI_RECORD_PATH,strlen(AI_RECORD_PATH)); + #ifdef AI_USE_PCM + memcpy((void*)path,AI_RECORD_PCM_PATH,strlen(AI_RECORD_PCM_PATH)); + #else + #define AI_RECORD_SBC_PATH "/user/userdata/AiRecording/AIAudio.sbc" + #endif FILE *fp= fopen(path,"r+"); if(fp) { @@ -3922,7 +3931,7 @@ bool get_AI_PATH_and_size(char *path,uint32_t *size) return false; } } -#define SEND_AIVOICE_SPEED 10 +#define SEND_AIVOICE_SPEED 30 //APP获取录音文件,录音文件上传 static void GetAiRecordCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totaldata,uint8_t crcvalue) { @@ -3944,7 +3953,6 @@ static void GetAiRecordCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota { int num=(ble_nus_max_data_len-18); if(num>482)num=482; - sendbigDataBufState = true;//分包同步数据不允许打断 char *data= (char *)malloc(num+1); @@ -3959,7 +3967,6 @@ static void GetAiRecordCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota printf("fopen fail %s\r\n",file_name); goto GetAiRecordFail; } - do { memset_s(data,num+1,0,num+1); @@ -3972,9 +3979,6 @@ static void GetAiRecordCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota } while (read_size==num); free(data); fclose(fp); - sendbigDataBufState = false; - - }else { GetAiRecordFail: @@ -3982,7 +3986,6 @@ static void GetAiRecordCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *tota value[18] = Calculate_CRC(value,18); sendBleData(value,19); } - sendbigDataBufState = false; } diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index b59c0c35e..160458b17 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -306,8 +306,14 @@ void svr_ble_connstate_change_cb(unsigned short conn_id, bd_addr_t *addr, gap_bl set_phone_info(addr); //扫描ios的ANCS服务,扫描到服务后会自动建立连接,并订阅服务 - // if(get_notify_switch()) - // ble_ancs_client_cmd_setup_and_subscribe(g_ble_conn_id); + if(get_notify_switch()) + ble_ancs_client_cmd_setup_and_subscribe(g_ble_conn_id); + + //int ret= a2dp_snk_connect(addr); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addr: ****%02x%02x%02x%02x playing_state: %x\n", + // g_bd_addr.addr[3], g_bd_addr.addr[2], g_bd_addr.addr[1], g_bd_addr.addr[0], g_bd_addr.type); /* 3 2 1 0 idx */ + + //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"state(int): %x\n", ret); Bleconnect = GAP_BLE_STATE_CONNECTED;//蓝牙已连接 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GAP_BLE_STATE_CONNECTED!!! 0x%x\r\n",pair_state); @@ -938,7 +944,8 @@ errcode_t svr_ble_bt_gatts_noyify(uint8_t *data, uint16_t data_len)//这里是 errcode_t ret = gatts_notify_indicate(g_ble_server_id, g_ble_conn_id, &data_info); if(ret!=ERRCODE_SUCC) { - gatts_notify_indicate(g_ble_server_id, g_ble_conn_id, &data_info); + msleep(50); + ret=gatts_notify_indicate(g_ble_server_id, g_ble_conn_id, &data_info); } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "gatts_notify_indicate ret:0x%x. serverid:%u,conn_id:%u,handle:%u.data_len:%d", ret, g_ble_server_id, g_ble_conn_id, g_ble_server_handle,data_len); @@ -996,7 +1003,7 @@ errcode_t svr_ble_read_data_value_updata_noyify(void)//2ae2 return ret; } -//static uint8_t flag=1; +static uint8_t flag=1; static void svr_ble_bt_gatts_req_read_cb(uint8_t server_id, uint16_t conn_id, gatts_req_read_cb_t *read_cb_para, errcode_t status) { @@ -1009,7 +1016,7 @@ static void svr_ble_bt_gatts_req_read_cb(uint8_t server_id, uint16_t conn_id, ga // if(flag==0) // ble_ancs_client_cmd_setup_and_subscribe(g_ble_conn_id); // else if(flag==1) - // ble_ancs_client_subscribe_notify(g_ble_conn_id,1); + // a2dp_snk_connect(&disconect_addr);//ble_ancs_client_subscribe_notify(g_ble_conn_id,1); // else if(flag==2) // ble_ancs_client_subscribe_data(g_ble_conn_id,1); // else if (flag==3) -- 2.17.1