From: penglei <1624952103@qq.com> Date: Thu, 3 Jul 2025 03:28:37 +0000 (+0800) Subject: 优化血压数据获取 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=09994cc1eb761aa3e2a5f02a6d90cb25f65759a9;p=mirrors%2FFD230.git 优化血压数据获取 --- diff --git a/code/sdk/drivers/peripheral/bp/bn02/bn02.c b/code/sdk/drivers/peripheral/bp/bn02/bn02.c index 7cbd15c31..850dde185 100644 --- a/code/sdk/drivers/peripheral/bp/bn02/bn02.c +++ b/code/sdk/drivers/peripheral/bp/bn02/bn02.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2025-01-16 12:35:15 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-01 15:17:47 + * @LastEditTime: 2025-07-03 09:43:02 * @FilePath: /sdk615/code/sdk/zhihui/drivers/bp/bn02/bn02.c * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -37,25 +37,14 @@ static FILE *fp = NULL; static int data_cnt = 0; static uint8_t *bn02_data = NULL; -// static int data[16 * 5 * 60] = {0}; - -// int data = ((rxByte[i] & 0xff) << 16) -// + ((rxByte[i + 1] & 0xff) << 8) -// + (rxByte[i + 2] & 0xff); -// if (data >= DATA_HANDLE / 2) { -// data -= DATA_HANDLE; -// } -// 其中:DATA_HANDLE = 2^24 - - bool Bn02_write_reg(uint8_t data) { - uint8_t cnt = pm_veto_get_id_cnt(PM_ID_BP); - if (cnt == 0) - { - uapi_pm_add_sleep_veto(PM_ID_BP); - } + // uint8_t cnt = pm_veto_get_id_cnt(PM_ID_BP); + // if (cnt == 0) + // { + // uapi_pm_add_sleep_veto(PM_ID_BP); + // } i2c_data_t i2c_data; i2c_data.send_buf = &data; @@ -67,11 +56,12 @@ bool Bn02_write_reg(uint8_t data) if (ret != ERRCODE_SUCC) printf("i2c Write data write fail! ret=0x%x\n", ret); - cnt = pm_veto_get_id_cnt(PM_ID_BP); - if (cnt == 1) - { - uapi_pm_remove_sleep_veto(PM_ID_BP); - } + + // cnt = pm_veto_get_id_cnt(PM_ID_BP); + // if (cnt == 1) + // { + // uapi_pm_remove_sleep_veto(PM_ID_BP); + // } return 1; } @@ -79,11 +69,11 @@ bool Bn02_write_reg(uint8_t data) bool Bn02_reads(uint8_t *data,int len) { - uint8_t cnt = pm_veto_get_id_cnt(PM_ID_BP); - if (cnt == 0) - { - uapi_pm_add_sleep_veto(PM_ID_BP); - } + // uint8_t cnt = pm_veto_get_id_cnt(PM_ID_BP); + // if (cnt == 0) + // { + // uapi_pm_add_sleep_veto(PM_ID_BP); + // } i2c_data_t i2c_data; i2c_data.send_buf = NULL; @@ -95,11 +85,11 @@ bool Bn02_reads(uint8_t *data,int len) if (ret != ERRCODE_SUCC) printf("i2c read data fail! ret=0x%x\n", ret); - cnt = pm_veto_get_id_cnt(PM_ID_BP); - if (cnt == 1) - { - uapi_pm_remove_sleep_veto(PM_ID_BP); - } + // cnt = pm_veto_get_id_cnt(PM_ID_BP); + // if (cnt == 1) + // { + // uapi_pm_remove_sleep_veto(PM_ID_BP); + // } return 1; } @@ -180,7 +170,6 @@ void bn02_int_handle(void) data_cnt = 0; memset(bn02_data,0,MAX_CNT); } - } else { @@ -191,7 +180,6 @@ void bn02_int_handle(void) // { // printf("222data[%d]:%d\n",i,tcp_data[i]); // } - data_cnt += 48; } } @@ -199,75 +187,6 @@ void bn02_int_handle(void) if(bn02_get_ble_status()) bn02_replymsg(bn02_buf,48,1); - // if(fp) - // { - // if(data_cnt >= 16 * 5 * 60) - // { - - // } - // else - // { - // data_cnt += cnt; - // if(fwrite(bn02_buf,sizeof(int),cnt,fp) != cnt) - // printf("bn02 fwrite failed\n"); - // else - // printf("bn02 fwrite succed data_cnt:%d\n",cnt); - // } - - // } - - - // printf("data_cnt:%d\n",data_cnt); - - // if(data_cnt >= 16 * 5 * 60 && fp) - // { - // int *data_array = (int *)malloc(data_cnt * sizeof(int)); - - // if (!data_array) - // { - // printf("内存分配失败\n"); - // } - // else - // { - // int read_count = 0; - - // fseek(fp, 0, SEEK_SET); - - // while (read_count < data_cnt && fread(&data_array[read_count], sizeof(int), 1, fp) == 1) - // { - // printf("%d ", data_array[read_count]); - // read_count++; - - // if (read_count % 10 == 0) - // printf("\n"); - // } - - // printf("\n实际读取数据: %d 个\n", read_count); - - // if (feof(fp)) - // printf("已读取所有数据\n"); - // else if (ferror(fp)) - // { - // printf("读取数据时发生错误\n"); - // free(data_array); - // data_array = NULL; - // } - - - // free(data_array); - // data_array = NULL; - - // // 清空文件内容(将文件指针移到文件开头并截断文件) - // fclose(fp); // 关闭文件 - // if(remove(BN02_FILE) != 0) - // printf("remove %s failed\n",BN02_FILE); - // else - // printf("remove %s succed\n",BN02_FILE); - - // bn02_stop(); - // } - // } - } void bn02_start(void) @@ -299,6 +218,12 @@ void bn02_stop(void) Bn02_write_reg(BN02_STOP_CMD); Bn02_Power_Ctrl(0); + // uint8_t cnt = pm_veto_get_id_cnt(PM_ID_BP); + // if (cnt == 1) + // { + // uapi_pm_remove_sleep_veto(PM_ID_BP); + // } + // do_bp_tcp_server_send_data(BP_TCP_SERVICE_CMD_SERVER_DEINIT,NULL,0); #if 0 diff --git a/code/sdk/drivers/peripheral/bp/service/bp_at_cmd.c b/code/sdk/drivers/peripheral/bp/service/bp_at_cmd.c index 14ec573c5..2910c3633 100644 --- a/code/sdk/drivers/peripheral/bp/service/bp_at_cmd.c +++ b/code/sdk/drivers/peripheral/bp/service/bp_at_cmd.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-12-23 15:11:01 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-06-25 11:03:03 + * @LastEditTime: 2025-07-02 16:34:24 * @FilePath: /sdk615/code/sdk/zhihui/drivers/bp/HP4570/service/bp_at_cmd.c * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -73,7 +73,7 @@ static uint32_t bn02_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd) // PRINT("SKIP bptest start, already start\r\n"); // return 0; // } - bp_start(); + bp_start(BP); g_bp_test_started = 1; }else if (start == 2){ // if (g_bp_test_started == 0) @@ -82,7 +82,7 @@ static uint32_t bn02_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd) // return 0; // } bp_stop(); - g_bp_test_started = 0 ; + g_bp_test_started = 0; }else if (start == 3){ // if (g_bp_test_started == 0) // { diff --git a/code/sdk/drivers/peripheral/bp/service/bp_ble_service.c b/code/sdk/drivers/peripheral/bp/service/bp_ble_service.c index abb388eed..1ea0519b7 100644 --- a/code/sdk/drivers/peripheral/bp/service/bp_ble_service.c +++ b/code/sdk/drivers/peripheral/bp/service/bp_ble_service.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2025-02-14 10:30:21 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-06-30 09:29:50 + * @LastEditTime: 2025-07-03 11:28:00 * @FilePath: /sdk615/code/sdk/zhihui/drivers/bp/service/bp_ble_service.c * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -107,7 +107,7 @@ errcode_t bn02_parse_frame(uint8_t *buf, uint16_t event_size) if(buf[7] == 0) { - bp_start(); + bp_start(BP); ble_status = 1; } else if(buf[7] == 1) diff --git a/code/sdk/drivers/peripheral/bp/service/bp_service.c b/code/sdk/drivers/peripheral/bp/service/bp_service.c index caf0f875a..1b87df3de 100644 --- a/code/sdk/drivers/peripheral/bp/service/bp_service.c +++ b/code/sdk/drivers/peripheral/bp/service/bp_service.c @@ -11,6 +11,7 @@ #include "bp_service.h" #include "custom_utils.h" #include "bn02.h" +#include "pm_definition.h" // #include "custom_runtime.h" /*** @@ -134,16 +135,23 @@ void bp_get_measure_time(uint32_t *b_time,uint32_t *e_time) *e_time = end_time; } -void bp_start(void) +void bp_start(uint8_t type) { if(uapi_dev_runtime_get_bp_status_flag()) { printf("bp service already started!\n"); return; } + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_BP); + if (cnt == 0) + { + uapi_pm_add_sleep_veto(PM_ID_BP); + } + uapi_dev_runtime_set_bp_status(1); do_bp_service_check_msg(BP_SERVICE_CMD_START_CHECK); uapi_get_timestampe_ss(&begin_time); + bp_set_measure_type(type); } void bp_stop(void) @@ -156,6 +164,13 @@ void bp_stop(void) uapi_dev_runtime_set_bp_status(0); do_bp_service_check_msg(BP_SERVICE_CMD_STOP_CHECK); uapi_get_timestampe_ss(&end_time); + + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_BP); + if (cnt == 1) + { + uapi_pm_remove_sleep_veto(PM_ID_BP); + } + } // void bp_service_service_resume(void) // { diff --git a/code/sdk/drivers/peripheral/bp/service/bp_service.h b/code/sdk/drivers/peripheral/bp/service/bp_service.h index 028050f47..8f660ca49 100644 --- a/code/sdk/drivers/peripheral/bp/service/bp_service.h +++ b/code/sdk/drivers/peripheral/bp/service/bp_service.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-12-23 15:11:01 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-06-25 11:04:44 + * @LastEditTime: 2025-07-02 15:21:44 * @FilePath: /sdk615/code/sdk/zhihui/drivers/charge/HP4570/service/charge_service.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -31,10 +31,14 @@ extern "C" { #define BP_SERVICE_CMD_STOP_CHECK 0x13 #define BP_SERVICE_CMD_TIMER_CHECK 0x11 +#define EMO 6 //情绪 +#define BP 7 //血压 +#define BP_ADJUST 10 //血压校准 + errcode_t uapi_bp_service_init(void); void bp_int_callback(pin_t pin, uintptr_t param); -void bp_start(void); +void bp_start(uint8_t type); void bp_stop(void); void bp_get_measure_time(uint32_t *b_time,uint32_t *e_time); diff --git a/code/sdk/drivers/peripheral/bp/service/bp_tcp_server.c b/code/sdk/drivers/peripheral/bp/service/bp_tcp_server.c index a6b7889d7..8fbbf0b7e 100644 --- a/code/sdk/drivers/peripheral/bp/service/bp_tcp_server.c +++ b/code/sdk/drivers/peripheral/bp/service/bp_tcp_server.c @@ -56,12 +56,15 @@ static int tcp_data_cnt = 0; static int g_listen_sock = -1; static uint8_t LK_STATUS = 0; +static uint8_t BP_GET_STATUS = 0; static int bp_sbp = 0; static int bp_dbp = 0; static char *imei = NULL; +static uint8_t bp_measure_type = 0; + //激活码 zzzm3K72zxRRLPX2utu5vMZcM269/8/7ZGOHVvONFt7WPAlQT++RJjzzrHj5v5DdlnmeELWI1FUPVJb96/5mOA== #define BP_ACTIVE_CODE_FILE "/user/system/bp_active_code.bin" @@ -76,6 +79,17 @@ struct bp_ipaddr_t ip_addr_t ip; }; +void bp_set_adjust_data(int sbp,int dbp) +{ + bp_sbp = sbp; + bp_dbp = dbp; +} + +void bp_set_measure_type(uint8_t type) +{ + bp_measure_type = type; +} + void bp_get_data(int *sbp,int *dbp) { if(sbp == NULL || dbp == NULL) @@ -147,10 +161,8 @@ static void bp_get_active_code(char *active_code,int len) return; } - // 初始化缓冲区 memset(buffer, 0, len); - // 安全读取文件内容(最多len-1字节,留一个位置给\0) size_t bytes_read = fread(buffer, 1, len - 1, file); if (bytes_read > 0) { @@ -373,22 +385,18 @@ FAILED: void tcp_recv_data_handler(const char *input, int input_len) { - // 检查输入基本格式 if (input_len < 2 || input[0] != '[' || input[input_len-1] != ']') { printf("解析失败: 格式错误(缺少方括号)\n"); return; } - // 移除首尾方括号 const char *data = input + 1; size_t data_len = input_len - 2; - // 查找逗号分隔符 const char *comma1 = memchr(data, ',', data_len); const char *comma2 = comma1 ? memchr(comma1 + 1, ',', data_len - (comma1 - data + 1)) : NULL; - - // 解析头部字段(BID*IMEI*长度*指令) + const char *star1 = memchr(data, '*', data_len); const char *star2 = star1 ? memchr(star1 + 1, '*', data_len - (star1 - data + 1)) : NULL; const char *star3 = star2 ? memchr(star2 + 1, '*', data_len - (star2 - data + 1)) : NULL; @@ -399,7 +407,6 @@ void tcp_recv_data_handler(const char *input, int input_len) return; } - // 提取头部各字段 const char *bid = data; const char *imei = star1 + 1; const char *len_str = star2 + 1; @@ -423,28 +430,23 @@ void tcp_recv_data_handler(const char *input, int input_len) return; } - // 解析内容长度(16进制转10进制) uint32_t content_len = 0; sscanf(len_str, "%x", &content_len); printf("解析后的内容长度: %u\n", content_len); - - // 处理不同格式情况 + if (comma1 && comma2) { - // 有两个逗号,完整格式 size_t status_len = comma2 - (comma1 + 1); size_t base64_len = data_len - (comma2 - data + 1); printf("状态码: %.*s\n", (int)status_len, comma1 + 1); - // 验证状态码 if (strncmp(comma1 + 1, "200", status_len) != 0) { printf("解析失败: 状态码必须为200,实际: %.*s\n", (int)status_len, comma1 + 1); return; } - - // Base64解码 + size_t decoded_len = (base64_len * 3) / 4 + 1; unsigned char *decoded_data = malloc(decoded_len); if (!decoded_data) @@ -463,8 +465,7 @@ void tcp_recv_data_handler(const char *input, int input_len) return; } decoded_data[actual_decoded_len] = '\0'; - - // 解析JSON数据 + cJSON *json_data = cJSON_Parse((const char *)decoded_data); free(decoded_data); @@ -473,11 +474,9 @@ void tcp_recv_data_handler(const char *input, int input_len) printf("解析失败: JSON解析失败,原始数据: %s\n", decoded_data); return; } - - // 打印JSON数据 + printf("JSON数据: %s\n", cJSON_Print(json_data)); - // 提取关键JSON字段 cJSON *status = cJSON_GetObjectItem(json_data, "status"); cJSON *data_obj = cJSON_GetObjectItem(json_data, "data"); cJSON *activation_code = cJSON_GetObjectItem(data_obj, "activation_code"); @@ -507,12 +506,7 @@ void tcp_recv_data_handler(const char *input, int input_len) printf("dbp: %d\n", dbp->valueint); bp_dbp = dbp->valueint; - if (g_listen_sock >= 0) - { - lwip_close(g_listen_sock); - g_listen_sock = -1; - LK_STATUS = 0; - } + BP_GET_STATUS = 1; } } @@ -558,7 +552,10 @@ int tcp_send(int listen_socket, const char *data, size_t size) } if(listen_socket < 0) + { + printf("listen_socket < 0 \n"); return -1; + } int ret = 0; @@ -685,10 +682,10 @@ int tcp_sign_up(void) if(imei == NULL) { uint8_t retry = 0; - while((imei == NULL || strlen(imei) == 0) && retry < 10) + while((imei == NULL || strlen(imei) == 0) && retry < 5) { retry++; - LOS_Msleep(2000); + LOS_Msleep(1000); imei = uapi_dev_runtime_get_cat1_imei(); } @@ -759,7 +756,7 @@ int tcp_sign_up(void) // 发送数据 tcp_send(g_listen_sock, send_str, send_len); - + LOS_Msleep(1000); FAILED: // 释放资源 if(head_str != NULL) @@ -835,7 +832,7 @@ int calculate_base64_length(int cnt) return base64_length; } -void upload_bp_data(int *data, int cnt) +static void upload_bp_data(int *data, int cnt) { #if 0 if (data == NULL || cnt == 0 || LK_STATUS == 0) @@ -1160,11 +1157,6 @@ FAILED: if (data == NULL || cnt == 0) return; - uint8_t pm_cnt = pm_veto_get_id_cnt(PM_ID_CAT1); - if (pm_cnt == 0) { - uapi_pm_add_sleep_veto(PM_ID_CAT1); - } - int ret = -1; char *data_str = NULL; int data_len = 0; @@ -1187,26 +1179,6 @@ FAILED: char *header_json = NULL; int encode_header_len = 0; - if(imei == NULL) - { - uint8_t retry = 0; - while((imei == NULL || strlen(imei) == 0) && retry < 10) - { - retry++; - LOS_Msleep(2000); - imei = uapi_dev_runtime_get_cat1_imei(); - } - - if (imei == NULL || strlen(imei) == 0) - { - printf("IMEI get failed\n"); - ret = -1; - goto FAILED; - } - } - - - printf("imei:%s\n", imei); // 获取测量时间 bp_get_measure_time(&begin_time, &end_time); @@ -1277,11 +1249,13 @@ FAILED: // temp_len += snprintf(json_data + temp_len, json_len - temp_len, "\"device_code\":\"%s\",", "864430010001091"); temp_len += snprintf(json_data + temp_len, json_len - temp_len, "\"device_code\":\"%s\",", imei); temp_len += snprintf(json_data + temp_len, json_len - temp_len, "\"measure_mode\":\"%d\",", 1); - temp_len += snprintf(json_data + temp_len, json_len - temp_len, "\"measure_type\":\"%d\",", 7); + temp_len += snprintf(json_data + temp_len, json_len - temp_len, "\"measure_type\":\"%d\",", bp_measure_type); temp_len += snprintf(json_data + temp_len, json_len - temp_len, "\"begin_time\":\"%s\",", begin_time_str); temp_len += snprintf(json_data + temp_len, json_len - temp_len, "\"end_time\":\"%s\",", end_time_str); temp_len += snprintf(json_data + temp_len, json_len - temp_len, "\"ppg_data\":["); + // printf("bp_measure_type : %d\n",bp_measure_type); + for(int i = 0; i < cnt; i++) { if(i == (cnt - 1)) @@ -1296,10 +1270,18 @@ FAILED: temp_len += snprintf(json_data + temp_len, json_len - temp_len,"\"ppg_fs\":\"%d\"}", 81); + + // if(bp_measure_type == BP_ADJUST) + // { + // temp_len += snprintf(json_data + temp_len, json_len - temp_len, "\"cal_value\":[%d,%d],", 120,80); + // bp_sbp = 0; + // bp_dbp = 0; + // } + + if(temp_len > json_len) goto FAILED; - // 后续Base64编码和数据发送逻辑... encode_len = temp_len * 3 / 2; // printf("encode_len : %d\n", encode_len); encode_str = (char *)malloc(encode_len); @@ -1383,6 +1365,17 @@ FAILED: goto FAILED; } + while(BP_GET_STATUS != 1) + { + LOS_Msleep(5000); + ret = tcp_send(g_listen_sock, send_str, send_len); + if(ret != 0) + { + printf("tcp_send failed\n"); + goto FAILED; + } + } + // int offset = 0; // while (offset < send_len) @@ -1393,8 +1386,6 @@ FAILED: // offset += chunk_len; // } - LOS_Msleep(3000); - FAILED: if (encode_header_str != NULL) @@ -1457,11 +1448,6 @@ FAILED: encode_str = NULL; } - pm_cnt = pm_veto_get_id_cnt(PM_ID_CAT1); - if (pm_cnt == 1) { - uapi_pm_remove_sleep_veto(PM_ID_CAT1); - } - // printf("free\n"); #endif } @@ -1485,26 +1471,6 @@ int bp_tcp_login(void) char len_str[5] = {0}; char md5_str[33] = {0}; // char json_data[1024] = {0}; - - if(imei == NULL) - { - uint8_t retry = 0; - while((imei == NULL || strlen(imei) == 0) && retry < 10) - { - retry++; - LOS_Msleep(2000); - imei = uapi_dev_runtime_get_cat1_imei(); - } - - if (imei == NULL || strlen(imei) == 0) - { - printf("IMEI get failed\n"); - ret = -1; - goto FAILED; - } - } - - printf("imei:%s\n", imei); char *json_data = (char *)malloc(512); if(json_data == NULL) @@ -1624,7 +1590,7 @@ int bp_tcp_login(void) // 发送数据 tcp_send(g_listen_sock, send_str, send_len); - + LOS_Msleep(2000); ret = 0; // 成功 FAILED: @@ -1821,7 +1787,7 @@ int get_active_code(void) // 发送数据 tcp_send(g_listen_sock, send_str, send_len); - + LOS_Msleep(2000); ret = 0; // 成功 FAILED: @@ -1888,11 +1854,12 @@ void bp_tcp_data_clean(void) tcp_data = NULL; tcp_data_cnt = 0; } - // if (g_listen_sock >= 0) - // { - // lwip_close(g_listen_sock); - // g_listen_sock = -1; - // } + if (g_listen_sock >= 0) + { + lwip_close(g_listen_sock); + g_listen_sock = -1; + } + BP_GET_STATUS = 0; } void do_bp_tcp_server_send_data(int cmd,int *data,uint32_t len) @@ -1959,36 +1926,20 @@ void bp_activate_algorithm(void) void bp_tcp_init(void) { - // printf("bp_tcp_init \n"); - - uint8_t retry = 0; - - uint8_t pm_cnt = pm_veto_get_id_cnt(PM_ID_CAT1); - if (pm_cnt == 0) { - uapi_pm_add_sleep_veto(PM_ID_CAT1); - } - - while (LK_STATUS == 0 && retry < 5) - { - retry++; - LOS_Msleep(2000); - tcp_sign_up(); - } + tcp_sign_up(); + if(LK_STATUS == 0 ) { printf("LK failed\n"); - goto FAILED; + return; } - // printf("retry : %d\n"); - retry = 0; char token[64] = {0}; bp_get_token(token, 64); - while(strlen(token) == 0 && retry < 5) + + if(strlen(token) == 0) { - printf("bp_get_token:%s\n", token); - retry++; bp_tcp_login(); LOS_Msleep(2000); bp_get_token(token, 64); @@ -1997,15 +1948,7 @@ void bp_tcp_init(void) if (strlen(token) == 0) { printf("token get failed\n"); - goto FAILED; - } - else - printf("token get succed\n"); - -FAILED: - pm_cnt = pm_veto_get_id_cnt(PM_ID_CAT1); - if (pm_cnt == 1) { - uapi_pm_remove_sleep_veto(PM_ID_CAT1); + return; } } @@ -2032,8 +1975,13 @@ static void tcp_data_handler(int *data,int len) // } // memset((void*)tcp_data,0,MAX_CNT * sizeof(int)); LOS_Msleep(1000); - upload_bp_data(tcp_data,tcp_data_cnt); - tcp_data_cnt = 0; + + if(LK_STATUS == 1) + upload_bp_data(tcp_data,tcp_data_cnt); + else + printf("NOT LK\n"); + + LOS_Msleep(2000); bp_tcp_data_clean(); } else @@ -2084,7 +2032,12 @@ static void bp_tcp_server_send_task(void const *arg) void bp_tcp_server_recv_task(void *pvParameters) { - char rx_buffer[512] = {0}; + char *rx_buffer = (char *)malloc(2048); + if(rx_buffer == NULL) + { + printf("rx_buffer malloc failed\n"); + return; + } uint8_t retry = 0; while (1) { @@ -2109,7 +2062,7 @@ void bp_tcp_server_recv_task(void *pvParameters) continue; } else - do_bp_tcp_server_send_data(BP_TCP_SERVICE_CMD_SERVER_INIT,NULL,0); + bp_tcp_init(); } // if (tcp_socket_init() != 0) @@ -2131,13 +2084,12 @@ void bp_tcp_server_recv_task(void *pvParameters) // printf("tcp_sign_up\n"); // 接收数据 - memset(rx_buffer, 0, sizeof(rx_buffer)); - int len = recv(g_listen_sock, rx_buffer, sizeof(rx_buffer) - 1, 0); + memset(rx_buffer, 0, 2048); + int len = recv(g_listen_sock, rx_buffer, 2048 - 1, 0); if (len > 0) { rx_buffer[len] = '\0'; - printf("recv len : %d\n",len); - PRINT("Received %d bytes: %s\n", len, rx_buffer); + printf("Received %d bytes: %s\n", len, rx_buffer); tcp_recv_data_handler(rx_buffer,len); // 解析数据 diff --git a/code/sdk/drivers/peripheral/bp/service/bp_tcp_server.h b/code/sdk/drivers/peripheral/bp/service/bp_tcp_server.h index 6f224d769..7f39ed87e 100644 --- a/code/sdk/drivers/peripheral/bp/service/bp_tcp_server.h +++ b/code/sdk/drivers/peripheral/bp/service/bp_tcp_server.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2025-02-14 10:30:32 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-06-30 09:23:22 + * @LastEditTime: 2025-07-02 14:04:37 * @FilePath: /sdk615/code/sdk/zhihui/drivers/bp/service/bp_ble_service.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -39,6 +39,9 @@ int tcp_sign_up(void); int bp_tcp_login(void); void bp_activate_algorithm(void); void bp_get_data(int *sbp,int *dbp); +void bp_set_measure_type(uint8_t type); + +void bp_set_adjust_data(int sbp,int dbp); #ifdef __cplusplus #if __cplusplus