From 177a3eb55aa5a3bb8969ada5aeb35ba2fc4a492d Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Mon, 9 Sep 2024 18:51:00 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E5=A4=9A=E6=AE=B5=E7=9D=A1?= =?utf8?q?=E7=9C=A0=E6=96=87=E4=BB=B6=E5=AD=98=E5=82=A8=EF=BC=8C=E4=BC=98?= =?utf8?q?=E5=8C=96=E6=B7=BB=E5=8A=A0cywee=E5=AF=86=E9=92=A5=E7=9A=84AT?= =?utf8?q?=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/sleep/src/SleepModel.cpp | 33 +++++---- .../msg_center/src/msg_center_customer.cpp | 2 +- .../drivers/peripheral/cywee/src/main_dml.c | 1 + .../peripheral/utils/custom_utils_at_cmd.c | 71 +++++++++++++++++-- 4 files changed, 88 insertions(+), 19 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp index 5fa418323..c481d6d9b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp @@ -1,8 +1,8 @@ /* * @Author: penglei 1624952103@qq.com * @Date: SLEPPNOTIFY24-06-26 19:36:48 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-07 17:56:51 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-09-09 18:25:14 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp * @Description: * @@ -251,29 +251,34 @@ namespace OHOS memset(status_file_path,0,sizeof(status_file_path)); sprintf_s(status_file_path, 64, SLEEP_STATUS_PATH, day); fp = fopen(status_file_path, "wb+"); - + if(fp == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "save_sleep_data fopen fail"); + return false; + } history_wake_up_timestamp = data->wake_up_timestamp; + fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp); } else { - fp = fopen(status_file_path, "ab+"); + fp = fopen(status_file_path, "rb+"); + if(fp == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "save_sleep_data fopen fail"); + return false; + } + if(history_wake_up_timestamp != data->wake_up_timestamp) { + fseek(fp, -sizeof(SLEEP_STATE_T), SEEK_END); SLEEP_STATE_T sleep_status = {0,0}; sleep_status.stat = 3; //清醒状态 - sleep_status.timestamp = history_wake_up_timestamp + 60; //时间戳为上一次的出睡时间 加 1分钟 + sleep_status.timestamp = history_wake_up_timestamp; //清醒状态时间为上一次的出睡时间 history_wake_up_timestamp = data->wake_up_timestamp; //更新历史出睡时间戳 - fwrite(&sleep_status, sizeof(SLEEP_STATE_T), 1, fp); + fwrite(&sleep_status, sizeof(SLEEP_STATE_T), 1, fp); //替换历史出睡数据 改为清醒状态 + fwrite(&data->sleep_status[1], sizeof(SLEEP_STATE_T), data->status_num - 1, fp); //跳过入睡状态写入文件 } } - - if (fp == NULL) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "save_sleep_data fopen fail"); - return false; - } - fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp); - fclose(fp); return true; } diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 61fed1c35..e22e786df 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -1295,7 +1295,7 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req) { sleep_data.sleep_status[state_num].timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60; sleep_data.sleep_status[state_num].stat = cywee_Inactivity_Info->status; - if(sleep_data.sleep_status[state_num].stat == 6 || sleep_data.sleep_status[state_num].stat == 13) + if(sleep_data.sleep_status[state_num].stat == 7 || sleep_data.sleep_status[state_num].stat == 13) { uapi_get_timestampe_ss(×tamp); sleep_data.sleep_status[state_num].timestamp = timestamp; diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 74603685e..7d584c645 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -834,6 +834,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { { uapi_dev_runtime_set_sleep_status(1); uapi_get_timestampe_ss(&asleep_timestampe); + break; //入睡通知不发消息,直接退出 } else if(c_inactivity_result_t.status == 4 || c_inactivity_result_t.status == 13) { diff --git a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c index be8844a0b..8981256e3 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c @@ -51,6 +51,36 @@ static int ConvertCmdToParam(uint8_t *para, uint32_t paraLen, return CUSTOM_UTILS_SUCCESS; } +#ifdef CYWEE_MAC_ACTIVE + +static int MyConvertCmdToParam(uint8_t *para, uint32_t paraLen, + uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN], uint32_t* argc) +{ + uint32_t pos = 0; + *argc = 0; + for (uint32_t i = 0; i < paraLen; i++) { + if ((para[i] == ' ' || para[i] == '\n') && pos != 0) { + argv[*argc][pos] = '\0'; + *argc += 1; + pos = 0; + if (*argc >= CUSTOM_UTILS_MAX_ARGC) { + return CUSTOM_UTILS_FAILED; + } + } else if (para[i] != ','){ + argv[*argc][pos] = para[i]; + pos++; + if (pos >= CUSTOM_UTILS_MAX_ARGV_LEN) { + return CUSTOM_UTILS_FAILED; + } + } + } + if (pos != 0) { + *argc += 1; + } + + return CUSTOM_UTILS_SUCCESS; +} +#endif static uint32_t custom_utils_setsn(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { @@ -1129,12 +1159,13 @@ static uint32_t custom_cywee_save_mac_key(uint8_t *para, uint32_t paraLen, char { UNUSED(strCommonCmd); +#ifdef CYWEE_MAC_ACTIVE uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = { 0 }; uint32_t argc = 0; - uint8_t send_data[8] = {0}; - + uint8_t *send_data = NULL; + uint8_t *tmp_data = NULL; - int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + int ret = MyConvertCmdToParam(para, paraLen, argv, &argc); if (ret != CUSTOM_UTILS_SUCCESS) { wstp_print("CUSTOM_UTILSTEST ATCMD Convert Command Failed\n"); return ERRCODE_FAIL; @@ -1145,9 +1176,41 @@ static uint32_t custom_cywee_save_mac_key(uint8_t *para, uint32_t paraLen, char return ERRCODE_FAIL; } int16_t len = atol((char*)argv[0]); + tmp_data = (uint8_t *)malloc(len * 2); + if(tmp_data == NULL) + { + wstp_print("MALLOC FAILED\r\n"); + return ERRCODE_FAIL; + } + + + for(int i = 0; i < len * 2; i++) + { + if(argv[1][i] >=65) + argv[1][i] = argv[1][i] - 65 + 10; + else + argv[1][i] = argv[1][i] - 48; + tmp_data[i] = argv[1][i]; + + } + send_data = (uint8_t *)malloc(len); + if(send_data == NULL) + { + free(tmp_data); + wstp_print("MALLOC FAILED\r\n"); + return ERRCODE_FAIL; + } - uapi_cywee_save_mac_key(argv[1],len); + for(int i = 0,j = 0; i < len * 2 ; i+=2 , j++) + { + send_data[j] = tmp_data[i] * 16 | tmp_data[i+1]; + wstp_print("tmp_data[%d] : 0X%2X\n",j,send_data[j]); + } + uapi_cywee_save_mac_key(send_data,len); + free(send_data); + free(tmp_data); +#endif return ERRCODE_SUCC; } -- 2.17.1