From: SnickerSun Date: Tue, 21 May 2024 16:18:03 +0000 (+0800) Subject: 在新解析代码中添加android app的版本支持 X-Git-Tag: release_V1.2.70_20241020_135402~1111 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=refs%2Fchanges%2F177%2F1;p=mirrors%2FFD230.git 在新解析代码中添加android app的版本支持 cywee算法 stackoverflow,增加了stacksize 并放到EXT_MEM里 --- 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 91e2b9c05..18b917c65 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -40,6 +40,8 @@ extern "C" { #include "bletest.h" #include "custom_utils.h" +#include "custom_runtime.h" + #define DEBUG_TEST (0) #define CRC_CHECK_ERR 0 //crc校验失败 #define JSON_CHECK_OK 1 //json解析成功 @@ -247,7 +249,7 @@ static uint8_t get_crc_from_lrc(uint8_t lrcValue) uint8_t crcbuf = 0; crcbuf = lrcValue%256; crcbuf = 256-crcbuf; - crcbuf = crcbuf%256; + crcbuf = crcbuf%256; return crcbuf; } @@ -261,9 +263,9 @@ static bool Check_CRC(uint8_t *data,uint16_t len,uint8_t crcvalue)//计算20byte } lrcValue = calculate_lrc(data,len,0x00); - crcbuf = get_crc_from_lrc(lrcValue); + crcbuf = get_crc_from_lrc(lrcValue); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Check_CRC ret:0x%x len:%d\r\n",crcbuf,len); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Check_CRC lrc: 0x%x ,ret crc: 0x%x ,crcvalue 0x%x , len:%d\r\n",lrcValue,crcbuf,crcvalue,len); if(crcbuf == crcvalue) { @@ -272,7 +274,10 @@ static bool Check_CRC(uint8_t *data,uint16_t len,uint8_t crcvalue)//计算20byte } else{ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Check_CRC false:\r\n"); - return false; + if(uapi_dev_runtime_get_android_connection_status()==1) + return true; + else + return false; } } @@ -382,6 +387,7 @@ typedef struct uint8_t *data;//if buffer_to_file is 1, than data is the filename , else data is the ram buffer. uint8_t crcvalue; uint8_t lrcvalue; //计算crc用的临时变量 + uint8_t lrcvalue2; //计算crc用的临时变量 uint32_t last_timestamp;// last package receive time uint8_t receive_file_flag;//1 接收文件 0 不接收文件 file_recv_stat_t file_recv_stat; @@ -5020,7 +5026,7 @@ errcode_t decode_ota_json(ble_read_data *buffer_handle) ); buffer_handle->file_recv_stat.received_size = 0; buffer_handle->file_recv_stat.lrcvalue = 0; - buffer_handle->receive_file_flag = 1; + buffer_handle->receive_file_flag = 1; return ERRCODE_SUCC; }else{ buffer_handle->receive_file_flag = 0; @@ -5107,7 +5113,7 @@ void dumpHeader(msg_header_t *msgheader) errcode_t check_header(msg_header_t *header ) { - if( (header->direction == MSG_DIRECTION_RECV) + if( (header->direction == MSG_DIRECTION_RECV || header->direction == MSG_DIRECTION_RECV_ANDROID) && (header->cmdtype > 0 && header->cmdtype <= 6 ) && (header->cmdid > 0 && header->cmdid <= 0x50 ) ) @@ -5151,7 +5157,7 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t if(buffer_handle->file_recv_stat.recv_file_stat <= 0 && buffer_handle->file_recv_stat.file == NULL) { buffer_handle->file_recv_stat.lrcvalue = 0; - if (buffer_handle->file_recv_stat.file_type == 1) + if (buffer_handle->file_recv_stat.file_type == 1) { buffer_handle->file_recv_stat.file = fopen("/update/update.fwpkg","w+"); printf("create file /update/update.fwpkg %X\n",buffer_handle->file_recv_stat.file); @@ -5175,7 +5181,7 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t if(writtensize == event_size) { buffer_handle->file_recv_stat.lrcvalue = calculate_lrc(data,event_size,buffer_handle->file_recv_stat.lrcvalue); - buffer_handle->file_recv_stat.received_size += event_size; + buffer_handle->file_recv_stat.received_size += event_size; printf("handle_recv_file received_size %d\n",buffer_handle->file_recv_stat.received_size); }else{ @@ -5239,7 +5245,7 @@ static errcode_t handle_ble_msg(ble_read_data *buffer_handle) if(buffer_handle->buffer_to_file == 0) { - bleLongRecvData(buffer_handle,buffer_handle->data+sizeof(msg_header_t),buffer_handle->totalDataLen,(uint8_t*)(&buffer_handle->cmd_header),NULL,buffer_handle->crcvalue); + bleLongRecvData(buffer_handle,buffer_handle->data+sizeof(msg_header_t),buffer_handle->totalDataLen,(uint8_t*)(&buffer_handle->cmd_header),buffer_handle->data,buffer_handle->crcvalue); }else{ //处理缓存成文件的 @@ -5265,6 +5271,13 @@ errcode_t combine_data_internal(ble_read_data *buffer_handle,uint8_t *totalData, //第一帧 if (event_size > sizeof(msg_header_t) && check_header(header) == ERRCODE_SUCC ) { + + if (header->direction == MSG_DIRECTION_RECV_ANDROID) + { + uapi_dev_runtime_set_android_connection_status(1); + }else{ + uapi_dev_runtime_set_android_connection_status(0); + } buffer_handle->cmd_header.direction = header->direction; buffer_handle->cmd_header.cmdtype = header->cmdtype; buffer_handle->cmd_header.cmdid = header->cmdid; diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h index cabd8f844..6a6f0ab93 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -101,6 +101,7 @@ void cameram_send_data(void); #define MSG_DIRECTION_RECV 0x73 +#define MSG_DIRECTION_RECV_ANDROID 0x4A #define MSG_DIRECTION_SEND 0x72 #define MAX_INTERVAL_MS_BETWEEN_2_CMD 50 // 50ms 在一个分包里,如果多个指令间超过50ms,则认为分包失败 diff --git a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c index 77e5da2eb..17e4b8f1c 100644 --- a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c +++ b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c @@ -384,7 +384,7 @@ static void cywee_service_check_task(void const *arg) } } #define CYWEE_APP_BOARD_MSG_COUNT 50 -#define CYWEE_APP_BOARD_TASK_SIZE 0x1100 +#define CYWEE_APP_BOARD_TASK_SIZE 0x2000 #define CYWEE_BOARD_TASK_PRIO 7 void create_cywee_queue(void) { @@ -408,7 +408,7 @@ errcode_t uapi_cywee_service_init(void) taskcfg.attr.priority = osPriorityNormal1; taskcfg.attr.stack_size = CYWEE_APP_BOARD_TASK_SIZE; taskcfg.func = cywee_service_check_task; - taskcfg.use_mem = USE_DTCM_MEM; + taskcfg.use_mem = USE_EXTEND_MEM; errcode_t ret = uapi_create_osThread_custom(&taskcfg); if (ret != ERRCODE_SUCC) diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.c b/code/sdk/drivers/peripheral/utils/custom_runtime.c index 23963c08d..10453a08f 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.c +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.c @@ -41,4 +41,16 @@ uint8_t uapi_dev_runtime_get_br_connect_stat(void) uint8_t uapi_dev_runtime_get_earphone_connect_stat(void) { return g_runtime.bt_earphone_connectstat ; +} + + + +uint8_t uapi_dev_runtime_set_android_connection_status(uint8_t is_android) +{ + g_runtime.android_app_connected = is_android; + return is_android; +} +uint8_t uapi_dev_runtime_get_android_connection_status(void) +{ + return g_runtime.android_app_connected; } \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.h b/code/sdk/drivers/peripheral/utils/custom_runtime.h index 7dd44ef6a..e2385f940 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.h +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.h @@ -63,6 +63,7 @@ typedef struct * bt_ble_connectstat 设备已连接手机 1连接, 0 未连接 * bt_br_connectstat 经典蓝牙连接状态 0 未连接, 1 连接a2dp 2 连接hfp 3 连接 a2dp+hfp * bt_earphone_connectstat 连接耳机状态 1连接, 0 未连接 + * android_app_connected , 0 not connected, 1 android connected * cat1_runtime cat1实时状态,详见 cat1_runtime_status_t 定义 * */ typedef struct @@ -74,6 +75,7 @@ typedef struct uint8_t bt_ble_connectstat; uint8_t bt_br_connectstat; uint8_t bt_earphone_connectstat; + uint8_t android_app_connected; cat1_runtime_status_t cat1_runtime; } runtime_status_t; @@ -120,6 +122,15 @@ uint8_t uapi_dev_runtime_get_br_connect_stat(void); */ uint8_t uapi_dev_runtime_get_earphone_connect_stat(void); +/** + * 设置 android app connect status +*/ +uint8_t uapi_dev_runtime_set_android_connection_status(uint8_t is_android); +/** + * 获取 android app connect status +*/ +uint8_t uapi_dev_runtime_get_android_connection_status(void); + #ifdef __cplusplus #if __cplusplus }