From 0ed73cfdf964370b2f14ffe326804af5b8e46bba Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Thu, 21 Aug 2025 15:05:44 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E4=BA=A7=E6=B5=8BMAG=E3=80=81?= =?utf8?q?PPG=E3=80=81CYWEEAT=E3=80=81BT=E3=80=81=E5=BD=95=E9=9F=B3?= =?utf8?q?=E7=AD=89AT=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../zhihui/UI/producttest/src/testView.cpp | 2226 ++++++++--------- code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c | 10 +- code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h | 2 + .../drivers/cywee/service/cywee_at_cmd.c | 26 + .../zhihui/drivers/mag/mmc5603/mmc5603_main.c | 11 +- .../zhihui/drivers/mag/service/mag_at_cmd.c | 2 + code/sdk/zhihui/drivers/mag/service/mag_hal.h | 2 + code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c | 11 + code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h | 3 + .../pah8009/factory/pah800x_factory_test.c | 10 +- .../drivers/ppg/pah8009/sensor/pah800x_main.c | 34 +- .../zhihui/drivers/ppg/service/ppg_at_cmd.cpp | 5 + .../zhihui/drivers/vibrator/vibrator_at_cmd.c | 65 +- .../services/battery/test/battery_at_cmd.cpp | 18 + code/sdk/zhihui/utils/custom_utils.c | 8 +- code/sdk/zhihui/utils/custom_utils_at_cmd.c | 264 ++ code/sdk/zhihui/utilscpp/custom_utilscpp.cpp | 91 +- code/sdk/zhihui/utilscpp/custom_utilscpp.h | 6 +- 18 files changed, 1658 insertions(+), 1136 deletions(-) diff --git a/code/sdk/zhihui/UI/producttest/src/testView.cpp b/code/sdk/zhihui/UI/producttest/src/testView.cpp index 9a95103c9..d61afc662 100644 --- a/code/sdk/zhihui/UI/producttest/src/testView.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testView.cpp @@ -1,1114 +1,1114 @@ -#include "producttest/include/testView.h" -#include "producttest/include/testPresenter.h" -#include "producttest/include/testModel.h" -#include "components/ui_label_button.h" -#include "power_display_service.h" -#include "wearable_log.h" -#ifdef SUPPORT_CAT1_SERVICE -#include "cat1_server.h" -#include "cat1_ctl.h" -#include "cat1_server_hal.h" -#endif - -#include "custom_utils.h" -#include "custom_runtime.h" - -#ifdef FD230 -#include "factorytest_protocol.h" -#endif - -#ifdef __cplusplus -#if __cplusplus -extern "C" -{ -#endif -#endif -#include "pm_definition.h" -#include "pm_veto.h" -#include "pm.h" -#ifdef __cplusplus -#if __cplusplus -} -#endif -#endif - -namespace OHOS -{ - - static testView *g_pSystemView{nullptr}; - - // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。 - test_ext Test_ViewMapper_t[] = { - {TESTVIEW, "", "", "", &testView::ChangeSystemAboutView, false}, // 占位,空的 - {QRCODE, "QRCodeButton", "QRCode", "QRCodeButton_next", &testView::ChangeQRCodeTESTView, true}, - {VISON, "AboutTheWatchButton", "Verison", "AboutTheWatchButton_next", &testView::ChangeSystemAboutView, true}, - {LCD, "LCDButton", "LCD", "LCDButton_next", &testView::ChangeLCDTESTView, true}, - {TP, "TPButton", "TP", "TPButton_next", &testView::ChangeTPTESTView, true}, - {MAGETIC, "MAGETICButton", "Magetic", "MAGETICButton_next", &testView::ChangeMGTESTView, true}, - {LUMINANCE, "luminanceButton", "luminance", "luminanceButton_next", &testView::ChangLUMTESTView, true}, - {CHARG, "chargingButton", "bat&charger", "chargingButton_next", &testView::ChangchargingTESTView, true}, - {SPEAK, "speakButton", "speak", "speakButton_next", &testView::ChangspeakTESTView, true}, - {MOTOR, "motorButton", "motor", "motorButton_next", &testView::ChangmotorTESTView, true}, -#ifdef SUPPORT_CAT1_SERVICE - {CAT1, "cat1button", "CAT1", "cat1button_next", &testView::ChangeCAT1TESTView, true}, -#endif - {BUTTON, "buttonbutton", "oktestBtn", "buttonbutton_next", &testView::ChangKEYTESTView, true}, - {MICROPHONE, "microphonebutton", "microphone", "microphonebutton_next", &testView::ChangeMPTESTView, true}, - {HRSENSON, "hrsensonbutton", "hrsensor", "hrsensonbutton_next", &testView::ChangeHRTESTView, true}, - {GSENSON, "gsensonbutton", "gsensor", "gsensonbutton_next", &testView::ChangeGTESTView, true}, - {BTTEST, "BTbutton", "BT", "BTbutton_next", &testView::ChangeBTTESTView, true}, - {SEChipTest, "SEChipTestbutton", "SEChipTest", "SEChipTestbutton_next", &testView::ChangeSEChipTESTView, true}, - {PingTest, "PingTestbutton", "PingTest", "PingTestbutton_next", &testView::ChangePingTESTView, true}, -#if defined(SUPPORT_GNSS) - {GPSTEST, "GPSTestbutton", "GPSTest", "GPSTestbutton_next", &testView::ChangeGPSTESTView, true}, -#endif -#ifdef ENABLE_LQBP002TA - {PRESSURETEST, "pressureTestbutton", "pressureTest", "pressureTestbutton_next", &testView::ChangepressureTestTESTView, true}, -#endif -#ifdef AGINGTEST - {OLDTEST, "oldtestbutton", "aging", "oldtestexit", &testView::ChangeoldTESTView, true}, -#endif - {DEEPSLEEP, "deepsleep", "DeepSleepCurrent", "xxxxxxxxx", &testView::ChangeoldTESTView, true}, - {shutdown, "shutdown", "shutdown", "xxxxxxxxx", &testView::ChangeoldTESTView, true}, - {RESET, "reset", "reset", "xxxxxxxxx", &testView::ChangeoldTESTView, true}, - {FACTORYRESE, "FactoryReset", "FactoryReset", "xxxxxxxxx", &testView::ChangeoldTESTView, true}, -#ifdef SUPPORT_A5133_SERVICE - {RF5133, "RF5133", "RF5133", "xxxxxxxxx", &testView::ChangeA5133TESTView, true}, -#endif - - }; - - testView::testView() - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testView::testView"); - g_pSystemView = this; - } - - testView::~testView() - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testView::~testView"); - ClearAll(); - g_pSystemView = nullptr; - } - - testView *testView::GetInstance() - { - return g_pSystemView; - } - - void testView::ClearAll() - { - if (group) - { - group->RemoveAll(); - delete group; - group = nullptr; - if (SystemScrollView[TESTVIEW]) - { - SystemScrollView[TESTVIEW]->RemoveAll(); - delete SystemScrollView[TESTVIEW]; - SystemScrollView[TESTVIEW] = nullptr; - delete SystemLabel; - SystemLabel = nullptr; - int funcSize = sizeof(Test_ViewMapper_t) / sizeof(Test_ViewMapper_t[TESTVIEW]); - for (int i = 0; i < funcSize; i++) - { - if (button[i]) - { - delete button[i]; - button[i] = NULL; - } - } - } - } - if (test_about_view) - { - delete test_about_view; // 1 - test_about_view = nullptr; - } - - if (test_LCD_view) - { - delete test_LCD_view; // 2 - test_LCD_view = nullptr; - } - if (test_TP_view) - { - delete test_TP_view; // 3 - test_TP_view = nullptr; - } - if (test_lum_view) - { - delete test_lum_view; // 4 - test_lum_view = nullptr; - } - if (test_charging_view) - { - delete test_charging_view; // 5 - test_charging_view = nullptr; - } - if (test_speak_view) - { - delete test_speak_view; // 6 - test_speak_view = nullptr; - } - if (test_motor_view) - { - delete test_motor_view; // 7 - test_motor_view = nullptr; - } -#ifdef SUPPORT_CAT1_SERVICE - if (test_cat1_view) - { - delete test_cat1_view; // 8 - test_cat1_view = nullptr; - } -#endif - - if (test_KEY_view) - { - delete test_KEY_view; // 9 - test_KEY_view = nullptr; - } - if (test_MG_view) - { - delete test_MG_view; // 10 - test_MG_view = nullptr; - } - if (test_hr_view) - { - delete test_hr_view; // 11 - test_hr_view = nullptr; - } - if (test_MP_view) - { - delete test_MP_view; // 12 - test_MP_view = nullptr; - } - if (test_G_view) - { - delete test_G_view; // 13 - test_G_view = nullptr; - } -#ifdef SUPPORT_A5133_SERVICE - if (test_A5133_view) - { - delete test_A5133_view; // 13 - test_A5133_view = nullptr; - } -#endif - // delete test_G_view;//13 - // test_G_view= nullptr; - - for (int i = 1; i < 13; i++) - { - if (SystemScrollView[i]) - SystemScrollView[i] = nullptr; - } - if (test_Ping_view) - { - delete test_Ping_view; // PingTest - test_Ping_view = nullptr; - } - if (test_QRCode_view) - { - delete test_QRCode_view; // QRCode - test_QRCode_view = nullptr; - } -#ifdef SUPPORT_GNSS - if (test_GPS_view) - { - delete test_GPS_view; // GPS - test_GPS_view = nullptr; - } -#endif - } - - /// @brief 设置SystemScrollView - /// @param void - /// @return true 设置成功,false 失败 - bool testView::SetTheSystemScrollView(void) - { - SystemScrollView[TESTVIEW] = new UIScrollView(); - if (SystemScrollView[TESTVIEW] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SetTheSystemScrollView new fail!"); - return false; - } - SystemScrollView[TESTVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - SystemScrollView[TESTVIEW]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - SystemScrollView[TESTVIEW]->SetStyle(STYLE_BORDER_RADIUS, 0); - - SystemScrollView[TESTVIEW]->SetScrollBlankSize(35); - SystemScrollView[TESTVIEW]->SetReboundSize(50); - SystemScrollView[TESTVIEW]->SetDirection(1); - SystemScrollView[TESTVIEW]->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。 - SystemScrollView[TESTVIEW]->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。 - SystemScrollView[TESTVIEW]->SetSwipeACCLevel(200); /*设置手指抬起屏幕后的补偿距离。*/ - // UIView::OnDragListener *draglistener = static_cast(new SystemViewOnDragListener()); - // if (draglistener == nullptr) - // { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); - // return false; - // } - // SystemScrollView[TESTVIEW]->SetOnDragListener(draglistener); - SystemScrollView[TESTVIEW]->SetTouchable(true); - SystemScrollView[TESTVIEW]->SetDraggable(true); - return true; - } - - /// @brief 设置标题 - /// @param void - /// @return true 设置成功,false 失败 - bool testView::SetTheTitle(void) - { - SystemLabel = new UILabel(); - if (SystemLabel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemLabel new fail!"); - return false; - } - SystemLabel->SetPosition(162, 52); - SystemLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - SystemLabel->SetStyle(STYLE_TEXT_FONT, 30); - SystemLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - SystemLabel->SetText("GNT TEST"); - SystemLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - SystemLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - SystemLabel->SetRollSpeed(6); - SystemLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); - - return true; - } - - bool testView::AddResultButtons(UIScrollView *scrollView, int16_t viewId,UILabelButton*&oktestBtn,UILabelButton*&failtestBtn) - { - if (scrollView == nullptr) - { - return false; - } - - printf("目前测试项id:%d",viewId); - - // 创建新按钮(如果当前按钮为空) - if (oktestBtn == nullptr) - { - oktestBtn = new UILabelButton(); - if (oktestBtn == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButtonExt is error"); - return false; // 内存分配失败,返回false - } - oktestBtn->SetPosition(40, 80); - oktestBtn->Resize(135, 88); - - oktestBtn->SetStyle(STYLE_TEXT_FONT, 30); - oktestBtn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - } - if (failtestBtn == nullptr) - { - failtestBtn = new UILabelButton(); - if (failtestBtn == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButtonExt is error"); - return false; // 内存分配失败,返回false - } - failtestBtn->SetPosition(220, 80); - failtestBtn->Resize(135, 88); - - failtestBtn->SetStyle(STYLE_TEXT_FONT, 30); - failtestBtn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - } - - // 获取当前测试项状态 - test_status_enum status = testModel::GetInstance()->GetResult(viewId); - printf("目前该项的测试状态为:%d\n",status); - // 获取测试项描述 - std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(viewId); - printf("目前测试项的描述是:%s\n",viewDesc.c_str()); - - // 安全检查:确保viewDesc不为空 - if (viewDesc.empty()) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AddResultButtons: viewDesc is empty for viewId %d", viewId); - return false; - } - - if (oktestBtn) - { - oktestBtn->SetText("成功"); - oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER); - // 根据状态设置按钮样式 - switch (status) - { - case TEST_STATUS_NONE: - oktestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); - break; - case TEST_STATUS_SUCCESS: - oktestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); - break; - case TEST_STATUS_ERROR: - oktestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); - break; - } - - // 设置按钮标识 - 修复悬空指针问题 - okButtonViewId = "TestOK" + viewDesc; - printf("=== VIEWID DEBUG ===\n"); - printf("设置前 oktestBtn->GetViewId() = %s\n", oktestBtn->GetViewId()); - printf("准备设置 viewId = %s\n", okButtonViewId.c_str()); - printf("okButtonViewId 字符串地址 = %p\n", okButtonViewId.c_str()); - printf("okButtonViewId 字符串长度 = %zu\n", okButtonViewId.length()); - - oktestBtn->SetViewId(okButtonViewId.c_str()); - - printf("设置后 oktestBtn->GetViewId() = %s\n", oktestBtn->GetViewId()); - printf("设置后 oktestBtn->GetViewId() 地址 = %p\n", oktestBtn->GetViewId()); - printf("=== VIEWID DEBUG END ===\n"); - - // UIView::OnClickListener *clickListener = static_cast(testPresenter::GetInstance()); - oktestBtn->SetOnClickListener(presenter_); - scrollView->Add(oktestBtn); - } - - if (failtestBtn) - { - failtestBtn->SetText("失败"); - failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER); - - // 根据状态设置按钮样式 - switch (status) - { - case TEST_STATUS_NONE: - failtestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); - break; - case TEST_STATUS_SUCCESS: - failtestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); - break; - case TEST_STATUS_ERROR: - failtestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); - break; - } - - // 设置按钮标识(修复了原代码中的错误)- 修复悬空指针问题 - failButtonViewId = "TestNO" + viewDesc; - printf("=== VIEWID DEBUG FAIL BUTTON ===\n"); - printf("设置前 failtestBtn->GetViewId() = %s\n", failtestBtn->GetViewId()); - printf("准备设置 viewId = %s\n", failButtonViewId.c_str()); - printf("failButtonViewId 字符串地址 = %p\n", failButtonViewId.c_str()); - printf("failButtonViewId 字符串长度 = %zu\n", failButtonViewId.length()); - - failtestBtn->SetViewId(failButtonViewId.c_str()); - - printf("设置后 failtestBtn->GetViewId() = %s\n", failtestBtn->GetViewId()); - printf("设置后 failtestBtn->GetViewId() 地址 = %p\n", failtestBtn->GetViewId()); - printf("=== VIEWID DEBUG FAIL BUTTON END ===\n"); - - // UIView::OnClickListener *clickListener = static_cast(testPresenter::GetInstance()); - failtestBtn->SetOnClickListener(presenter_); - scrollView->Add(failtestBtn); - } - - return true; - } - - /// @brief 设置按钮 - /// @param oktestBtn - /// @return true 设置成功,false 失败 - - UILabelButtonExt *testView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener) - { - UILabelButtonExt *oktestBtn = new UILabelButtonExt(); - if (oktestBtn == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: oktestBtn new fail!"); - return nullptr; - } - oktestBtn->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); - oktestBtn->SetViewId(buttonconfig.ViewId); - oktestBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); - oktestBtn->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc); - oktestBtn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - oktestBtn->SetOnClickListener(clickListener); - - oktestBtn->SetText(buttonconfig.str); - oktestBtn->SetAlign(TEXT_ALIGNMENT_LEFT); - oktestBtn->SetLabelPosition(buttonconfig.label_x, buttonconfig.label_y); - oktestBtn->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, buttonconfig.Fontsize); - // oktestBtn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - - oktestBtn->SetImagePosition(326, 37); - return oktestBtn; - } - - void testView::initView_ext(int x, int y, int w, int h, int interval, const char *imagsrc) - { - if (!SetTheSystemScrollView()) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SetTheSystemScrollView() fail!"); - return; - } - if (!SetTheTitle()) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SetTheTitle() fail!"); - return; - } - /* -------------------------------------------------------------------------- */ - UIView::OnClickListener *clickListener = static_cast(testPresenter::GetInstance()); - /* -------------------------------------------------------------------------- */ - ButtonConfig_ext_t buttonconfig; - buttonconfig.x = x; - buttonconfig.y = y; - buttonconfig.w = w; - buttonconfig.h = h; - - int len = sizeof(Test_ViewMapper_t) / sizeof(Test_ViewMapper_t[0]); - - for (int i = 1; i < len; i++) - { - buttonconfig.str = Test_ViewMapper_t[i].Labe_str; - buttonconfig.ViewId = Test_ViewMapper_t[i].viewid_str; - buttonconfig.ImageSrc = imagsrc; - buttonconfig.label_x = 40; - buttonconfig.label_y = 0; - buttonconfig.Fontsize = 30; - buttonconfig.ALIGN = TEXT_ALIGNMENT_LEFT; - button[i] = SetTheButton_ext(buttonconfig, clickListener); - buttonconfig.y += interval; - } - /* -------------------------------------------------------------------------- */ - } - - // 0.跳转到系统视图,其他视图都市通过这个视图跳转 - bool testView::ChangeSystemView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemView"); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - // 1.跳转到关于手表 - bool testView::ChangeSystemAboutView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemAboutView"); - test_about_view = new testAboutView(); - if (test_about_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_about_view->SystemAbouTheWatchtInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangeLCDTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeLCDTESTView"); - test_LCD_view = new testLCDView(); - if (test_LCD_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_LCD_view->testLCDInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangeTPTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeTPTESTView"); - test_TP_view = new testTPView(); - if (test_TP_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_TP_view->testTPInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangeMGTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeMGTESTView"); - test_MG_view = new testMagicView(); - if (test_MG_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_MG_view->testmagicInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangLUMTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangLUMTESTView"); - test_lum_view = new testLUMView(); - if (test_lum_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_lum_view->testLUMInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangchargingTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangchargingTESTView"); - test_charging_view = new testCHANINGView(); - if (test_charging_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_charging_view->testCHANINGInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangspeakTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangspeakTESTView"); - test_speak_view = new testSPEAKView(); - if (test_speak_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_speak_view->testSPEAKInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangmotorTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangmotorTESTView"); - test_motor_view = new testMOTORView(); - if (test_motor_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_motor_view->testMOTORInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangeCAT1TESTView(int16_t thisView) - { -#ifdef SUPPORT_CAT1_SERVICE - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeCAT1TESTView"); - test_cat1_view = new testcat1View(); - if (test_cat1_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_cat1_view->testcat1InitIView(thisView); - group->Add(SystemScrollView[thisView]); - } -#endif - return true; - } - - bool testView::ChangKEYTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangKEYTESTView"); - test_KEY_view = new testbuttonView(); - if (test_KEY_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_KEY_view->testBUTTONInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangeMPTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeMPTESTView"); - test_MP_view = new testmicrohoneView(); - if (test_MP_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_MP_view->testmicrophoneInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangeHRTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeHRTESTView"); - test_hr_view = new testhrsenson1View(); - if (test_hr_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_hr_view->testhrsensonInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangeGTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeGTESTView"); - test_G_view = new testgsensonView(); - if (test_G_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_G_view->testGSENSONInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangeoldTESTView(int16_t thisView) - { -#ifdef AGINGTEST - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeoldTESTView"); - test_old_view = new testoldView(); - if (test_old_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_old_view->testoldInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } -#endif - return true; - } - - bool testView::ChangeBTTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeBTTESTView"); - test_BT_view = new testBTView(); - if (test_BT_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_BT_view->testBTInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangeSEChipTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView"); - test_SEChip_view = new testSEChipView(); - if (test_SEChip_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_SEChip_view->SEChipInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangePingTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangePingTESTView"); - test_Ping_view = new testPingView(); - if (test_Ping_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_Ping_view->testPingInitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - - bool testView::ChangeQRCodeTESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeQRCodeTESTView"); - test_QRCode_view = new testQRCodeView(); - if (test_QRCode_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_QRCode_view->testQRCodeInitIView((uint8_t)thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } - -#if defined(SUPPORT_GNSS) - bool testView::ChangeGPSTESTView(int16_t thisView) - { - - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView"); - test_GPS_view = new testGPSView(); - if (test_GPS_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_GPS_view->testGPSInitIView((uint8_t)thisView); - group->Add(SystemScrollView[thisView]); - } - - return true; - } -#endif -#ifdef ENABLE_LQBP002TA - bool testView::ChangepressureTestTESTView(int16_t thisView) - { - - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView"); - test_pressure_view = new testpressureView(); - if (test_pressure_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_pressure_view->testpressureInitIView((uint8_t)thisView); - group->Add(SystemScrollView[thisView]); - } - - return true; - } -#endif -#ifdef SUPPORT_A5133_SERVICE - bool testView::ChangeA5133TESTView(int16_t thisView) - { - if (SystemScrollView[thisView] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeA5133TESTView"); - test_A5133_view = new testA5133View(); - if (test_A5133_view == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); - return false; - } - SystemScrollView[thisView] = test_A5133_view->testA5133InitIView(thisView); - group->Add(SystemScrollView[thisView]); - } - return true; - } -#endif - - UIScrollView *testView::GetSystemScrollView(int ViewId) - { - if (SystemScrollView[ViewId] == nullptr) - { - return nullptr; - } - return SystemScrollView[ViewId]; - } - - /* -------------------------------------------------------------------------- */ - // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。 - - // 3.根据传入的interface参数执行相应视图ID关联的成员函数。 - bool testView::ClickFunc(int16_t interface) - { - int funcSize = sizeof(Test_ViewMapper_t) / sizeof(Test_ViewMapper_t[TESTVIEW]); - for (int i = 1; i < funcSize; i++) - { - if (interface == Test_ViewMapper_t[i].viewId) - { - bool jug = (this->*(Test_ViewMapper_t[i].func))(interface); - if (jug == false) - { - return false; - } - return true; - } - } - return false; - } - - // 4.切换视图 - void testView::ChangeView(int16_t hideView, int16_t showView) - { - if (hideView > MAX_TESTVIEWID) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: SystemViewId Overstep ones bounds"); - return; - } - if (SystemScrollView[hideView] != nullptr) - { - SystemScrollView[hideView]->SetVisible(false); - } - else - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: SystemScrollView[%d] is nullptr", hideView); - } - ClickFunc(showView); - if (SystemScrollView[showView] != nullptr) - { - SystemScrollView[showView]->SetVisible(true); - } - else - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: SystemScrollView[%d] is nullptr", showView); - } - if (hideView != 0) - { - switch (hideView) - { - case VISON: - group->Remove(SystemScrollView[hideView]); - delete test_about_view; - test_about_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case LCD: - group->Remove(SystemScrollView[hideView]); - delete test_LCD_view; - test_LCD_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case TP: - group->Remove(SystemScrollView[hideView]); - delete test_TP_view; - test_TP_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case MAGETIC: - group->Remove(SystemScrollView[hideView]); - delete test_MG_view; - test_MG_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case LUMINANCE: - group->Remove(SystemScrollView[hideView]); - delete test_lum_view; - test_lum_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case CHARG: - group->Remove(SystemScrollView[hideView]); - delete test_charging_view; - test_charging_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - - case SPEAK: - group->Remove(SystemScrollView[hideView]); - delete test_speak_view; - test_speak_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case MOTOR: - group->Remove(SystemScrollView[hideView]); - delete test_motor_view; - test_motor_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; -#ifdef SUPPORT_CAT1_SERVICE - case CAT1: - group->Remove(SystemScrollView[hideView]); - delete test_cat1_view; - test_cat1_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; -#endif - case BUTTON: - group->Remove(SystemScrollView[hideView]); - delete test_KEY_view; - test_KEY_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case MICROPHONE: - group->Remove(SystemScrollView[hideView]); - delete test_MP_view; - test_MP_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case HRSENSON: - group->Remove(SystemScrollView[hideView]); - delete test_hr_view; - test_hr_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case GSENSON: - group->Remove(SystemScrollView[hideView]); - delete test_G_view; - test_G_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case OLDTEST: - group->Remove(SystemScrollView[hideView]); - delete test_old_view; - test_old_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case BTTEST: - group->Remove(SystemScrollView[hideView]); - delete test_BT_view; - test_BT_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case SEChipTest: - group->Remove(SystemScrollView[hideView]); - delete test_SEChip_view; - test_SEChip_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; - case PingTest: - group->Remove(SystemScrollView[hideView]); - delete test_Ping_view; - test_Ping_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; -#if defined(SUPPORT_GNSS) - case GPSTEST: - group->Remove(SystemScrollView[hideView]); - delete test_GPS_view; - test_GPS_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; -#endif -#ifdef SUPPORT_A5133_SERVICE - case RF5133: - group->Remove(SystemScrollView[hideView]); - delete test_A5133_view; - test_A5133_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; -#endif -#if defined(ENABLE_LQBP002TA) - case PRESSURETEST: - group->Remove(SystemScrollView[hideView]); - delete test_pressure_view; - test_pressure_view = nullptr; - SystemScrollView[hideView] = nullptr; - break; -#endif - default: - break; - } - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "change>>>>>>>>>>>hideView %d > showView %d >>>", hideView, showView); - } - /* -------------------------------------------------------------------------- */ - - void testView::OnStart() - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnStart>>>>>>>>>>>>>"); - - if (group == nullptr) - { - group = new UIViewGroup(); - if (group == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeGroupView new fail!"); - } - } - group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - group->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - group->SetTouchable(true); - group->SetDraggable(true); - - // InitIView(); - initView_ext(43, 120, 380, 100, 120, "/user/res/SETTING_NEXT.bin"); - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - if (display_api->get_screen_state() != SCREEN_ON) - { - display_api->turn_on_screen(); - } - display_api->set_auto_timeout_function(false); - - uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cnt : %d\n", cnt); - if (cnt == 0) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_pm_add_sleep_veto(PM_ID_P_TEST);"); - uapi_pm_add_sleep_veto(PM_ID_P_TEST); - } - - if (!uapi_dev_runtime_get_factory_test_status_flag()) - uapi_set4GCapability(true); - - start_custom_ble_service(); - - if (SystemScrollView[TESTVIEW] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: OnSetUpView has nullptr"); - return; - } - SystemScrollView[TESTVIEW]->Add(SystemLabel); - int len = sizeof(Test_ViewMapper_t) / sizeof(Test_ViewMapper_t[0]); - for (int i = 0; i < len; i++) - { - SystemScrollView[TESTVIEW]->Add(button[i]); - } - group->Add(SystemScrollView[TESTVIEW]); - AddViewToRootContainer(group); - } - +#include "producttest/include/testView.h" +#include "producttest/include/testPresenter.h" +#include "producttest/include/testModel.h" +#include "components/ui_label_button.h" +#include "power_display_service.h" +#include "wearable_log.h" +#ifdef SUPPORT_CAT1_SERVICE +#include "cat1_server.h" +#include "cat1_ctl.h" +#include "cat1_server_hal.h" +#endif + +#include "custom_utils.h" +#include "custom_runtime.h" + +#ifdef FD230 +#include "factorytest_protocol.h" +#endif + +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif +#endif +#include "pm_definition.h" +#include "pm_veto.h" +#include "pm.h" +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif + +namespace OHOS +{ + + static testView *g_pSystemView{nullptr}; + + // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。 + test_ext Test_ViewMapper_t[] = { + {TESTVIEW, "", "", "", &testView::ChangeSystemAboutView, false}, // 占位,空的 + {QRCODE, "QRCodeButton", "QRCode", "QRCodeButton_next", &testView::ChangeQRCodeTESTView, true}, + {VISON, "AboutTheWatchButton", "Verison", "AboutTheWatchButton_next", &testView::ChangeSystemAboutView, true}, + {LCD, "LCDButton", "LCD", "LCDButton_next", &testView::ChangeLCDTESTView, true}, + {TP, "TPButton", "TP", "TPButton_next", &testView::ChangeTPTESTView, true}, + {MAGETIC, "MAGETICButton", "Magetic", "MAGETICButton_next", &testView::ChangeMGTESTView, true}, + {LUMINANCE, "luminanceButton", "luminance", "luminanceButton_next", &testView::ChangLUMTESTView, true}, + {CHARG, "chargingButton", "bat&charger", "chargingButton_next", &testView::ChangchargingTESTView, true}, + {SPEAK, "speakButton", "speak", "speakButton_next", &testView::ChangspeakTESTView, true}, + {MOTOR, "motorButton", "motor", "motorButton_next", &testView::ChangmotorTESTView, true}, +#ifdef SUPPORT_CAT1_SERVICE + {CAT1, "cat1button", "CAT1", "cat1button_next", &testView::ChangeCAT1TESTView, true}, +#endif + {BUTTON, "buttonbutton", "oktestBtn", "buttonbutton_next", &testView::ChangKEYTESTView, true}, + {MICROPHONE, "microphonebutton", "microphone", "microphonebutton_next", &testView::ChangeMPTESTView, true}, + {HRSENSON, "hrsensonbutton", "hrsensor", "hrsensonbutton_next", &testView::ChangeHRTESTView, true}, + {GSENSON, "gsensonbutton", "gsensor", "gsensonbutton_next", &testView::ChangeGTESTView, true}, + {BTTEST, "BTbutton", "BT", "BTbutton_next", &testView::ChangeBTTESTView, true}, + {SEChipTest, "SEChipTestbutton", "SEChipTest", "SEChipTestbutton_next", &testView::ChangeSEChipTESTView, true}, + {PingTest, "PingTestbutton", "PingTest", "PingTestbutton_next", &testView::ChangePingTESTView, true}, +#if defined(SUPPORT_GNSS) + {GPSTEST, "GPSTestbutton", "GPSTest", "GPSTestbutton_next", &testView::ChangeGPSTESTView, true}, +#endif +#ifdef ENABLE_LQBP002TA + {PRESSURETEST, "pressureTestbutton", "pressureTest", "pressureTestbutton_next", &testView::ChangepressureTestTESTView, true}, +#endif +#ifdef AGINGTEST + {OLDTEST, "oldtestbutton", "aging", "oldtestexit", &testView::ChangeoldTESTView, true}, +#endif + {DEEPSLEEP, "deepsleep", "DeepSleepCurrent", "xxxxxxxxx", &testView::ChangeoldTESTView, true}, + {shutdown, "shutdown", "shutdown", "xxxxxxxxx", &testView::ChangeoldTESTView, true}, + {RESET, "reset", "reset", "xxxxxxxxx", &testView::ChangeoldTESTView, true}, + {FACTORYRESE, "FactoryReset", "FactoryReset", "xxxxxxxxx", &testView::ChangeoldTESTView, true}, +#ifdef SUPPORT_A5133_SERVICE + {RF5133, "RF5133", "RF5133", "xxxxxxxxx", &testView::ChangeA5133TESTView, true}, +#endif + + }; + + testView::testView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testView::testView"); + g_pSystemView = this; + } + + testView::~testView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testView::~testView"); + ClearAll(); + g_pSystemView = nullptr; + } + + testView *testView::GetInstance() + { + return g_pSystemView; + } + + void testView::ClearAll() + { + if (group) + { + group->RemoveAll(); + delete group; + group = nullptr; + if (SystemScrollView[TESTVIEW]) + { + SystemScrollView[TESTVIEW]->RemoveAll(); + delete SystemScrollView[TESTVIEW]; + SystemScrollView[TESTVIEW] = nullptr; + delete SystemLabel; + SystemLabel = nullptr; + int funcSize = sizeof(Test_ViewMapper_t) / sizeof(Test_ViewMapper_t[TESTVIEW]); + for (int i = 0; i < funcSize; i++) + { + if (button[i]) + { + delete button[i]; + button[i] = NULL; + } + } + } + } + if (test_about_view) + { + delete test_about_view; // 1 + test_about_view = nullptr; + } + + if (test_LCD_view) + { + delete test_LCD_view; // 2 + test_LCD_view = nullptr; + } + if (test_TP_view) + { + delete test_TP_view; // 3 + test_TP_view = nullptr; + } + if (test_lum_view) + { + delete test_lum_view; // 4 + test_lum_view = nullptr; + } + if (test_charging_view) + { + delete test_charging_view; // 5 + test_charging_view = nullptr; + } + if (test_speak_view) + { + delete test_speak_view; // 6 + test_speak_view = nullptr; + } + if (test_motor_view) + { + delete test_motor_view; // 7 + test_motor_view = nullptr; + } +#ifdef SUPPORT_CAT1_SERVICE + if (test_cat1_view) + { + delete test_cat1_view; // 8 + test_cat1_view = nullptr; + } +#endif + + if (test_KEY_view) + { + delete test_KEY_view; // 9 + test_KEY_view = nullptr; + } + if (test_MG_view) + { + delete test_MG_view; // 10 + test_MG_view = nullptr; + } + if (test_hr_view) + { + delete test_hr_view; // 11 + test_hr_view = nullptr; + } + if (test_MP_view) + { + delete test_MP_view; // 12 + test_MP_view = nullptr; + } + if (test_G_view) + { + delete test_G_view; // 13 + test_G_view = nullptr; + } +#ifdef SUPPORT_A5133_SERVICE + if (test_A5133_view) + { + delete test_A5133_view; // 13 + test_A5133_view = nullptr; + } +#endif + // delete test_G_view;//13 + // test_G_view= nullptr; + + for (int i = 1; i < 13; i++) + { + if (SystemScrollView[i]) + SystemScrollView[i] = nullptr; + } + if (test_Ping_view) + { + delete test_Ping_view; // PingTest + test_Ping_view = nullptr; + } + if (test_QRCode_view) + { + delete test_QRCode_view; // QRCode + test_QRCode_view = nullptr; + } +#ifdef SUPPORT_GNSS + if (test_GPS_view) + { + delete test_GPS_view; // GPS + test_GPS_view = nullptr; + } +#endif + } + + /// @brief 设置SystemScrollView + /// @param void + /// @return true 设置成功,false 失败 + bool testView::SetTheSystemScrollView(void) + { + SystemScrollView[TESTVIEW] = new UIScrollView(); + if (SystemScrollView[TESTVIEW] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SetTheSystemScrollView new fail!"); + return false; + } + SystemScrollView[TESTVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SystemScrollView[TESTVIEW]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemScrollView[TESTVIEW]->SetStyle(STYLE_BORDER_RADIUS, 0); + + SystemScrollView[TESTVIEW]->SetScrollBlankSize(35); + SystemScrollView[TESTVIEW]->SetReboundSize(50); + SystemScrollView[TESTVIEW]->SetDirection(1); + SystemScrollView[TESTVIEW]->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。 + SystemScrollView[TESTVIEW]->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。 + SystemScrollView[TESTVIEW]->SetSwipeACCLevel(200); /*设置手指抬起屏幕后的补偿距离。*/ + // UIView::OnDragListener *draglistener = static_cast(new SystemViewOnDragListener()); + // if (draglistener == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); + // return false; + // } + // SystemScrollView[TESTVIEW]->SetOnDragListener(draglistener); + SystemScrollView[TESTVIEW]->SetTouchable(true); + SystemScrollView[TESTVIEW]->SetDraggable(true); + return true; + } + + /// @brief 设置标题 + /// @param void + /// @return true 设置成功,false 失败 + bool testView::SetTheTitle(void) + { + SystemLabel = new UILabel(); + if (SystemLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemLabel new fail!"); + return false; + } + SystemLabel->SetPosition(162, 52); + SystemLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemLabel->SetStyle(STYLE_TEXT_FONT, 30); + SystemLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + SystemLabel->SetText("GNT TEST"); + SystemLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + SystemLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + SystemLabel->SetRollSpeed(6); + SystemLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30); + + return true; + } + + bool testView::AddResultButtons(UIScrollView *scrollView, int16_t viewId,UILabelButton*&oktestBtn,UILabelButton*&failtestBtn) + { + if (scrollView == nullptr) + { + return false; + } + + printf("目前测试项id:%d",viewId); + + // 创建新按钮(如果当前按钮为空) + if (oktestBtn == nullptr) + { + oktestBtn = new UILabelButton(); + if (oktestBtn == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButtonExt is error"); + return false; // 内存分配失败,返回false + } + oktestBtn->SetPosition(40, 80); + oktestBtn->Resize(135, 88); + + oktestBtn->SetStyle(STYLE_TEXT_FONT, 30); + oktestBtn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + } + if (failtestBtn == nullptr) + { + failtestBtn = new UILabelButton(); + if (failtestBtn == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitButtonExt is error"); + return false; // 内存分配失败,返回false + } + failtestBtn->SetPosition(220, 80); + failtestBtn->Resize(135, 88); + + failtestBtn->SetStyle(STYLE_TEXT_FONT, 30); + failtestBtn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + } + + // 获取当前测试项状态 + test_status_enum status = testModel::GetInstance()->GetResult(viewId); + printf("目前该项的测试状态为:%d\n",status); + // 获取测试项描述 + std::string viewDesc = testModel::GetInstance()->GetTestItemDescription(viewId); + printf("目前测试项的描述是:%s\n",viewDesc.c_str()); + + // 安全检查:确保viewDesc不为空 + if (viewDesc.empty()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AddResultButtons: viewDesc is empty for viewId %d", viewId); + return false; + } + + if (oktestBtn) + { + oktestBtn->SetText("成功"); + oktestBtn->SetAlign(TEXT_ALIGNMENT_CENTER); + // 根据状态设置按钮样式 + switch (status) + { + case TEST_STATUS_NONE: + oktestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); + break; + case TEST_STATUS_SUCCESS: + oktestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); + break; + case TEST_STATUS_ERROR: + oktestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); + break; + } + + // 设置按钮标识 - 修复悬空指针问题 + okButtonViewId = "TestOK" + viewDesc; + printf("=== VIEWID DEBUG ===\n"); + printf("设置前 oktestBtn->GetViewId() = %s\n", oktestBtn->GetViewId()); + printf("准备设置 viewId = %s\n", okButtonViewId.c_str()); + printf("okButtonViewId 字符串地址 = %p\n", okButtonViewId.c_str()); + printf("okButtonViewId 字符串长度 = %zu\n", okButtonViewId.length()); + + oktestBtn->SetViewId(okButtonViewId.c_str()); + + printf("设置后 oktestBtn->GetViewId() = %s\n", oktestBtn->GetViewId()); + printf("设置后 oktestBtn->GetViewId() 地址 = %p\n", oktestBtn->GetViewId()); + printf("=== VIEWID DEBUG END ===\n"); + + // UIView::OnClickListener *clickListener = static_cast(testPresenter::GetInstance()); + oktestBtn->SetOnClickListener(presenter_); + scrollView->Add(oktestBtn); + } + + if (failtestBtn) + { + failtestBtn->SetText("失败"); + failtestBtn->SetAlign(TEXT_ALIGNMENT_CENTER); + + // 根据状态设置按钮样式 + switch (status) + { + case TEST_STATUS_NONE: + failtestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); + break; + case TEST_STATUS_SUCCESS: + failtestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Gray().full); + break; + case TEST_STATUS_ERROR: + failtestBtn->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); + break; + } + + // 设置按钮标识(修复了原代码中的错误)- 修复悬空指针问题 + failButtonViewId = "TestNO" + viewDesc; + printf("=== VIEWID DEBUG FAIL BUTTON ===\n"); + printf("设置前 failtestBtn->GetViewId() = %s\n", failtestBtn->GetViewId()); + printf("准备设置 viewId = %s\n", failButtonViewId.c_str()); + printf("failButtonViewId 字符串地址 = %p\n", failButtonViewId.c_str()); + printf("failButtonViewId 字符串长度 = %zu\n", failButtonViewId.length()); + + failtestBtn->SetViewId(failButtonViewId.c_str()); + + printf("设置后 failtestBtn->GetViewId() = %s\n", failtestBtn->GetViewId()); + printf("设置后 failtestBtn->GetViewId() 地址 = %p\n", failtestBtn->GetViewId()); + printf("=== VIEWID DEBUG FAIL BUTTON END ===\n"); + + // UIView::OnClickListener *clickListener = static_cast(testPresenter::GetInstance()); + failtestBtn->SetOnClickListener(presenter_); + scrollView->Add(failtestBtn); + } + + return true; + } + + /// @brief 设置按钮 + /// @param oktestBtn + /// @return true 设置成功,false 失败 + + UILabelButtonExt *testView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener) + { + UILabelButtonExt *oktestBtn = new UILabelButtonExt(); + if (oktestBtn == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: oktestBtn new fail!"); + return nullptr; + } + oktestBtn->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + oktestBtn->SetViewId(buttonconfig.ViewId); + oktestBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + oktestBtn->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc); + oktestBtn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + oktestBtn->SetOnClickListener(clickListener); + + oktestBtn->SetText(buttonconfig.str); + oktestBtn->SetAlign(TEXT_ALIGNMENT_LEFT); + oktestBtn->SetLabelPosition(buttonconfig.label_x, buttonconfig.label_y); + oktestBtn->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, buttonconfig.Fontsize); + // oktestBtn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + oktestBtn->SetImagePosition(326, 37); + return oktestBtn; + } + + void testView::initView_ext(int x, int y, int w, int h, int interval, const char *imagsrc) + { + if (!SetTheSystemScrollView()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SetTheSystemScrollView() fail!"); + return; + } + if (!SetTheTitle()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SetTheTitle() fail!"); + return; + } + /* -------------------------------------------------------------------------- */ + UIView::OnClickListener *clickListener = static_cast(testPresenter::GetInstance()); + /* -------------------------------------------------------------------------- */ + ButtonConfig_ext_t buttonconfig; + buttonconfig.x = x; + buttonconfig.y = y; + buttonconfig.w = w; + buttonconfig.h = h; + + int len = sizeof(Test_ViewMapper_t) / sizeof(Test_ViewMapper_t[0]); + + for (int i = 1; i < len; i++) + { + buttonconfig.str = Test_ViewMapper_t[i].Labe_str; + buttonconfig.ViewId = Test_ViewMapper_t[i].viewid_str; + buttonconfig.ImageSrc = imagsrc; + buttonconfig.label_x = 40; + buttonconfig.label_y = 0; + buttonconfig.Fontsize = 30; + buttonconfig.ALIGN = TEXT_ALIGNMENT_LEFT; + button[i] = SetTheButton_ext(buttonconfig, clickListener); + buttonconfig.y += interval; + } + /* -------------------------------------------------------------------------- */ + } + + // 0.跳转到系统视图,其他视图都市通过这个视图跳转 + bool testView::ChangeSystemView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemView"); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + // 1.跳转到关于手表 + bool testView::ChangeSystemAboutView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSystemAboutView"); + test_about_view = new testAboutView(); + if (test_about_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_about_view->SystemAbouTheWatchtInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangeLCDTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeLCDTESTView"); + test_LCD_view = new testLCDView(); + if (test_LCD_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_LCD_view->testLCDInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangeTPTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeTPTESTView"); + test_TP_view = new testTPView(); + if (test_TP_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_TP_view->testTPInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangeMGTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeMGTESTView"); + test_MG_view = new testMagicView(); + if (test_MG_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_MG_view->testmagicInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangLUMTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangLUMTESTView"); + test_lum_view = new testLUMView(); + if (test_lum_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_lum_view->testLUMInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangchargingTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangchargingTESTView"); + test_charging_view = new testCHANINGView(); + if (test_charging_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_charging_view->testCHANINGInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangspeakTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangspeakTESTView"); + test_speak_view = new testSPEAKView(); + if (test_speak_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_speak_view->testSPEAKInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangmotorTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangmotorTESTView"); + test_motor_view = new testMOTORView(); + if (test_motor_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_motor_view->testMOTORInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangeCAT1TESTView(int16_t thisView) + { +#ifdef SUPPORT_CAT1_SERVICE + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeCAT1TESTView"); + test_cat1_view = new testcat1View(); + if (test_cat1_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_cat1_view->testcat1InitIView(thisView); + group->Add(SystemScrollView[thisView]); + } +#endif + return true; + } + + bool testView::ChangKEYTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangKEYTESTView"); + test_KEY_view = new testbuttonView(); + if (test_KEY_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_KEY_view->testBUTTONInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangeMPTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeMPTESTView"); + test_MP_view = new testmicrohoneView(); + if (test_MP_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_MP_view->testmicrophoneInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangeHRTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeHRTESTView"); + test_hr_view = new testhrsenson1View(); + if (test_hr_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_hr_view->testhrsensonInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangeGTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeGTESTView"); + test_G_view = new testgsensonView(); + if (test_G_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_G_view->testGSENSONInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangeoldTESTView(int16_t thisView) + { +#ifdef AGINGTEST + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeoldTESTView"); + test_old_view = new testoldView(); + if (test_old_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_old_view->testoldInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } +#endif + return true; + } + + bool testView::ChangeBTTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeBTTESTView"); + test_BT_view = new testBTView(); + if (test_BT_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_BT_view->testBTInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangeSEChipTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView"); + test_SEChip_view = new testSEChipView(); + if (test_SEChip_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_SEChip_view->SEChipInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangePingTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangePingTESTView"); + test_Ping_view = new testPingView(); + if (test_Ping_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_Ping_view->testPingInitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + + bool testView::ChangeQRCodeTESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeQRCodeTESTView"); + test_QRCode_view = new testQRCodeView(); + if (test_QRCode_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_QRCode_view->testQRCodeInitIView((uint8_t)thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } + +#if defined(SUPPORT_GNSS) + bool testView::ChangeGPSTESTView(int16_t thisView) + { + + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView"); + test_GPS_view = new testGPSView(); + if (test_GPS_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_GPS_view->testGPSInitIView((uint8_t)thisView); + group->Add(SystemScrollView[thisView]); + } + + return true; + } +#endif +#ifdef ENABLE_LQBP002TA + bool testView::ChangepressureTestTESTView(int16_t thisView) + { + + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView"); + test_pressure_view = new testpressureView(); + if (test_pressure_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_pressure_view->testpressureInitIView((uint8_t)thisView); + group->Add(SystemScrollView[thisView]); + } + + return true; + } +#endif +#ifdef SUPPORT_A5133_SERVICE + bool testView::ChangeA5133TESTView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeA5133TESTView"); + test_A5133_view = new testA5133View(); + if (test_A5133_view == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = test_A5133_view->testA5133InitIView(thisView); + group->Add(SystemScrollView[thisView]); + } + return true; + } +#endif + + UIScrollView *testView::GetSystemScrollView(int ViewId) + { + if (SystemScrollView[ViewId] == nullptr) + { + return nullptr; + } + return SystemScrollView[ViewId]; + } + + /* -------------------------------------------------------------------------- */ + // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。 + + // 3.根据传入的interface参数执行相应视图ID关联的成员函数。 + bool testView::ClickFunc(int16_t interface) + { + int funcSize = sizeof(Test_ViewMapper_t) / sizeof(Test_ViewMapper_t[TESTVIEW]); + for (int i = 1; i < funcSize; i++) + { + if (interface == Test_ViewMapper_t[i].viewId) + { + bool jug = (this->*(Test_ViewMapper_t[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } + } + return false; + } + + // 4.切换视图 + void testView::ChangeView(int16_t hideView, int16_t showView) + { + if (hideView > MAX_TESTVIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: SystemViewId Overstep ones bounds"); + return; + } + if (SystemScrollView[hideView] != nullptr) + { + SystemScrollView[hideView]->SetVisible(false); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: SystemScrollView[%d] is nullptr", hideView); + } + ClickFunc(showView); + if (SystemScrollView[showView] != nullptr) + { + SystemScrollView[showView]->SetVisible(true); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: SystemScrollView[%d] is nullptr", showView); + } + if (hideView != 0) + { + switch (hideView) + { + case VISON: + group->Remove(SystemScrollView[hideView]); + delete test_about_view; + test_about_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case LCD: + group->Remove(SystemScrollView[hideView]); + delete test_LCD_view; + test_LCD_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case TP: + group->Remove(SystemScrollView[hideView]); + delete test_TP_view; + test_TP_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case MAGETIC: + group->Remove(SystemScrollView[hideView]); + delete test_MG_view; + test_MG_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case LUMINANCE: + group->Remove(SystemScrollView[hideView]); + delete test_lum_view; + test_lum_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case CHARG: + group->Remove(SystemScrollView[hideView]); + delete test_charging_view; + test_charging_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + + case SPEAK: + group->Remove(SystemScrollView[hideView]); + delete test_speak_view; + test_speak_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case MOTOR: + group->Remove(SystemScrollView[hideView]); + delete test_motor_view; + test_motor_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; +#ifdef SUPPORT_CAT1_SERVICE + case CAT1: + group->Remove(SystemScrollView[hideView]); + delete test_cat1_view; + test_cat1_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; +#endif + case BUTTON: + group->Remove(SystemScrollView[hideView]); + delete test_KEY_view; + test_KEY_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case MICROPHONE: + group->Remove(SystemScrollView[hideView]); + delete test_MP_view; + test_MP_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case HRSENSON: + group->Remove(SystemScrollView[hideView]); + delete test_hr_view; + test_hr_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case GSENSON: + group->Remove(SystemScrollView[hideView]); + delete test_G_view; + test_G_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case OLDTEST: + group->Remove(SystemScrollView[hideView]); + delete test_old_view; + test_old_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case BTTEST: + group->Remove(SystemScrollView[hideView]); + delete test_BT_view; + test_BT_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case SEChipTest: + group->Remove(SystemScrollView[hideView]); + delete test_SEChip_view; + test_SEChip_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; + case PingTest: + group->Remove(SystemScrollView[hideView]); + delete test_Ping_view; + test_Ping_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; +#if defined(SUPPORT_GNSS) + case GPSTEST: + group->Remove(SystemScrollView[hideView]); + delete test_GPS_view; + test_GPS_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; +#endif +#ifdef SUPPORT_A5133_SERVICE + case RF5133: + group->Remove(SystemScrollView[hideView]); + delete test_A5133_view; + test_A5133_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; +#endif +#if defined(ENABLE_LQBP002TA) + case PRESSURETEST: + group->Remove(SystemScrollView[hideView]); + delete test_pressure_view; + test_pressure_view = nullptr; + SystemScrollView[hideView] = nullptr; + break; +#endif + default: + break; + } + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "change>>>>>>>>>>>hideView %d > showView %d >>>", hideView, showView); + } + /* -------------------------------------------------------------------------- */ + + void testView::OnStart() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnStart>>>>>>>>>>>>>"); + + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WatchQRCodeView::WatchQRCodeGroupView new fail!"); + } + } + group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + group->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + group->SetTouchable(true); + group->SetDraggable(true); + + // InitIView(); + initView_ext(43, 120, 380, 100, 120, "/user/res/SETTING_NEXT.bin"); + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->get_screen_state() != SCREEN_ON) + { + display_api->turn_on_screen(); + } + display_api->set_auto_timeout_function(false); + + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cnt : %d\n", cnt); + if (cnt == 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_pm_add_sleep_veto(PM_ID_P_TEST);"); + uapi_pm_add_sleep_veto(PM_ID_P_TEST); + } + + if (!uapi_dev_runtime_get_factory_test_status_flag()) + uapi_set4GCapability(true); + + start_custom_ble_service(); + + if (SystemScrollView[TESTVIEW] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: OnSetUpView has nullptr"); + return; + } + SystemScrollView[TESTVIEW]->Add(SystemLabel); + int len = sizeof(Test_ViewMapper_t) / sizeof(Test_ViewMapper_t[0]); + for (int i = 0; i < len; i++) + { + SystemScrollView[TESTVIEW]->Add(button[i]); + } + group->Add(SystemScrollView[TESTVIEW]); + AddViewToRootContainer(group); + } + } // namespace OHOS \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c b/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c index 02fec33ea..ddbd68ae8 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c @@ -116,6 +116,8 @@ static act_ext_result_t c_act_ext_result_t = {0}; uint8_t cywee_ble_service_flag = 0; +static uint8_t cywee_factory_log = 0; + #define SPORT_CHECK_MS 1000 #ifdef CYWEE_MAC_ACTIVE @@ -127,6 +129,11 @@ int cm__hs1__init(void); int cm__hs1__deinit(void); #endif +void cywee_set_factory_log_switch(uint8_t cmd) +{ + cywee_factory_log = cmd; +} + void cywee_get_sleep_time_data(uint32_t *fall_sleep_time,uint32_t *wake_up_time,uint16_t *total_time,uint8_t data_type) { if (fall_sleep_time == NULL || wake_up_time == NULL || total_time == NULL) @@ -1725,7 +1732,8 @@ void CWM_APSensorDataOutput_listen(const dml_sensorData_t * pSdo) } if (pSdo->validData & DML_SENSOR_DATA_VALID_ACC) { - //CWM_OS_dbgPrintf("acc: x=%.3f, y=%.3f, z=%.3f\n",pSdo->acc_data[0], pSdo->acc_data[1], pSdo->acc_data[2]); + if(cywee_factory_log) + CWM_OS_dbgPrintf("acc: x=%.3f, y=%.3f, z=%.3f\n",pSdo->acc_data[0], pSdo->acc_data[1], pSdo->acc_data[2]); rawdata[AccdataCount].acc_x = pSdo->acc_data[0]; rawdata[AccdataCount].acc_y = pSdo->acc_data[1]; rawdata[AccdataCount].acc_z = pSdo->acc_data[2]; diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h b/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h index 59d9c74db..6bb4ba687 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h @@ -206,6 +206,8 @@ void cywee_get_act_ext_data(act_ext_result_t *data); void cywee_get_sleep_time_data(uint32_t *fall_sleep_time,uint32_t *wake_up_time,uint16_t *total_time,uint8_t data_type); +void cywee_set_factory_log_switch(uint8_t cmd); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/zhihui/drivers/cywee/service/cywee_at_cmd.c b/code/sdk/zhihui/drivers/cywee/service/cywee_at_cmd.c index a7bdfb030..a73ed6d07 100644 --- a/code/sdk/zhihui/drivers/cywee/service/cywee_at_cmd.c +++ b/code/sdk/zhihui/drivers/cywee/service/cywee_at_cmd.c @@ -41,6 +41,31 @@ static int ConvertCmdToParam(uint8_t *para, uint32_t paraLen, } +// 新增的gsensor测试函数 +static uint32_t cywee_gsensor_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(strCommonCmd); + uint8_t argv[CYWEE_MAX_ARGC][CYWEE_MAX_ARGV_LEN] = { 0 }; + uint32_t argc = 0; + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != ERRCODE_SUCC) { + printf("CYWEE_GSENSOR ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + + if (argc != 1) { + printf("CYWEE_GSENSOR ATCMD Set Parameter Failed argc %d, should be AT^CYWEEGSENSOR=cmd\n", argc); + return ERRCODE_FAIL; + } + + uint8_t cmd = (uint8_t)atoi((char*)argv[0]); + + cywee_set_factory_log_switch(cmd); + + return ERRCODE_SUCC; +} + static uint32_t cywee_do_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { unused(strCommonCmd); @@ -105,6 +130,7 @@ static const at_cmd_table_t g_cywee_cmd[] = { { (char *)"AT^CYWEETEST", cywee_do_test, (char *)"free" }, { (char *)"AT^CYWEETEST", cywee_do_test, (char *)"pause" }, { (char *)"AT^CYWEETEST", cywee_do_test, (char *)"resume" }, + { (char *)"AT^CYWEEGSENSOR", cywee_gsensor_test, (char *)"1" }, }; at_cmd_table_t *get_cywee_cmd_table(uint32_t *cmd_count) diff --git a/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_main.c b/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_main.c index 54a24f95a..736a3890c 100644 --- a/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_main.c +++ b/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_main.c @@ -43,6 +43,8 @@ static float fAzimuth, fPitch, fRoll; /* This variable is used to save the calibration accuracy. */ static int iAccuracy; +static uint8_t mag_factory_log = 0; + /* Read saved calibration parameters. These para is saved in somewhere that can not disappear when power-off * ReadPara function should be create by customer.If customer can not implement this function, should comment it out * If there is no parameter saved, ReadPara() should return -1, else return 1; @@ -228,7 +230,9 @@ extern uint8_t is_xts_test_done(void); iAccuracy = GetMagAccuracy(); // MMC_LOG("fAzimuth =%f iAccuracy=%d\r\n",fAzimuth,iAccuracy); - + if(mag_factory_log) + printf("fAzimuth =%.3f\n",fAzimuth); + /* Get the SET Flag from algorithm */ // if(GetMagSaturation()) // { @@ -481,3 +485,8 @@ int mmc5603_stop(void) return 0; } + +void mag_set_factory_log_switch(uint8_t cmd) +{ + mag_factory_log = cmd; +} diff --git a/code/sdk/zhihui/drivers/mag/service/mag_at_cmd.c b/code/sdk/zhihui/drivers/mag/service/mag_at_cmd.c index 167940085..f44cbf26d 100644 --- a/code/sdk/zhihui/drivers/mag/service/mag_at_cmd.c +++ b/code/sdk/zhihui/drivers/mag/service/mag_at_cmd.c @@ -57,6 +57,7 @@ static uint32_t mag_start_test(uint8_t *para, uint32_t paraLen, char *strCommonC UNUSED(paraLen); UNUSED(para); do_mag_service_check_msg(MAG_SERVICE_CMD_START_CHECK); + mag_set_factory_log_switch(1); return ERRCODE_SUCC; } static uint32_t mag_stop_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd) @@ -65,6 +66,7 @@ static uint32_t mag_stop_test(uint8_t *para, uint32_t paraLen, char *strCommonCm UNUSED(paraLen); UNUSED(para); do_mag_service_check_msg(MAG_SERVICE_CMD_STOP_CHECK); + mag_set_factory_log_switch(0); return ERRCODE_SUCC; } static const at_cmd_table_t g_mag_cmd[] = { diff --git a/code/sdk/zhihui/drivers/mag/service/mag_hal.h b/code/sdk/zhihui/drivers/mag/service/mag_hal.h index d08ed3950..2531c1fa6 100644 --- a/code/sdk/zhihui/drivers/mag/service/mag_hal.h +++ b/code/sdk/zhihui/drivers/mag/service/mag_hal.h @@ -32,6 +32,8 @@ uint8_t mag_get_chip_id(void); void mag_get_iAccuracy(int *data); void mag_get_fAzimuth(float *data); +void mag_set_factory_log_switch(uint8_t cmd); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c b/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c index 5f8f48062..76f4df4f7 100644 --- a/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c +++ b/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c @@ -49,6 +49,7 @@ // S_AGPIO_R0 PRG_LED_POWER ON 心率等电源控制脚 #define GPIO_PIN_PRG_LED_ON S_AGPIO_R0 +static uint8_t ppg_factory_log = 0; void ppg_power_on(void) { @@ -196,3 +197,13 @@ void ppg_check_int(void) pah8009_check_int(); #endif } + +void ppg_set_factory_log_switch(uint8_t cmd) +{ + ppg_factory_log = cmd; +} + +uint8_t ppg_get_factory_log_switch(void) +{ + return ppg_factory_log; +} \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h b/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h index aef8c3944..cdb034bba 100644 --- a/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h +++ b/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h @@ -62,6 +62,9 @@ int32_t ppg_get_factory_data(void); void ppg_ble_send(uint8_t hr); void ppg_check_int(void); +void ppg_set_factory_log_switch(uint8_t cmd); +uint8_t ppg_get_factory_log_switch(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah800x_factory_test.c b/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah800x_factory_test.c index 5d5148dd4..153b81962 100644 --- a/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah800x_factory_test.c +++ b/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah800x_factory_test.c @@ -304,7 +304,7 @@ static void pah_sensor_factory_mode_verify_result(void) { _factory_state.verify_result.ch_result[i].is_passed = true; } - printf("ch[%d] : (min, value, max)=(%d, %d, %d), result=%d \n",\ + LOG_PRINT("ch[%d] : (min, value, max)=(%d, %d, %d), result=%d \n",\ i, _factory_state.verify_config.ch_spec[i].min, \ _factory_state.test_result.adc[i], \ _factory_state.verify_config.ch_spec[i].max, \ @@ -321,7 +321,7 @@ static void pah_sensor_factory_mode_verify_result(void) { _factory_state.verify_result.ch_result[i].is_passed = true; } - printf("ch[%d] : (min, value)=(%d, %d), result=%d \n",\ + LOG_PRINT("ch[%d] : (min, value)=(%d, %d), result=%d \n",\ i, _factory_state.verify_config.ch_spec[i].min, \ _factory_state.test_result.adc[i], \ _factory_state.verify_result.ch_result[i].is_passed); @@ -340,12 +340,14 @@ static void pah_sensor_factory_mode_verify_result(void) factory_test_ch[i] = _factory_state.test_result.adc[i]; - printf("ch[%d] : (value, max)=(%d, %d), result=%d \n",\ + LOG_PRINT("ch[%d] : (value, max)=(%d, %d), result=%d \n",\ i, _factory_state.test_result.adc[i], \ _factory_state.verify_config.ch_spec[i].max, \ _factory_state.verify_result.ch_result[i].is_passed); } } + + printf("ch[0]:%d,ch[1]:%d,ch[2]:%d\n",factory_test_ch[0],factory_test_ch[1],factory_test_ch[2]); } @@ -550,7 +552,7 @@ void pah8009_get_leaklight_data(uint16_t *ch0,uint16_t *ch1,uint16_t *ch2) *ch1 = factory_test_ch[1]; *ch2 = factory_test_ch[2]; - printf("factory_test_ch[0]:%d,factory_test_ch[0]:%d,factory_test_ch[0]:%d\n",factory_test_ch[0],factory_test_ch[1],factory_test_ch[2]); + printf("ch[0]:%d,ch[1]:%d,ch[2]:%d\n",factory_test_ch[0],factory_test_ch[1],factory_test_ch[2]); factory_test_ch[0] = 0; factory_test_ch[1] = 0; diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.c b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.c index 29acb7688..185c382c4 100644 --- a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.c +++ b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.c @@ -609,14 +609,19 @@ void hr_alg_task(void) if(time_cnt >= 20) { - time_cnt = 0; - // ppg_msg_callback_t func = ppg_get_send_msg_callback_func(); -#ifdef SUPPORT_CYWEE_SERVICE - // if(uapi_dev_runtime_get_train_status()) + if(ppg_get_factory_log_switch()) { - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CHECK_ACC, NULL); // 检查gsensor是否停止 + printf("green data : %d\n",factory_data); } -#endif + + time_cnt = 0; + // ppg_msg_callback_t func = ppg_get_send_msg_callback_func(); +// #ifdef SUPPORT_CYWEE_SERVICE +// // if(uapi_dev_runtime_get_train_status()) +// { +// do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CHECK_ACC, NULL); // 检查gsensor是否停止 +// } +// #endif if(hr > 0) { int hr_int = round(hr); @@ -972,14 +977,19 @@ void spo2_alg_task(void) if(time_cnt >= 20) { - time_cnt = 0; - // ppg_msg_callback_t func = ppg_get_send_msg_callback_func(); -#ifdef SUPPORT_CYWEE_SERVICE - // if(uapi_dev_runtime_get_train_status()) + if(ppg_get_factory_log_switch()) { - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CHECK_ACC, NULL); // 检查gsensor是否停止 + printf("red data : %d\n",factory_data); } -#endif + + time_cnt = 0; + // ppg_msg_callback_t func = ppg_get_send_msg_callback_func(); +// #ifdef SUPPORT_CYWEE_SERVICE +// // if(uapi_dev_runtime_get_train_status()) +// { +// do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CHECK_ACC, NULL); // 检查gsensor是否停止 +// } +// #endif } // ppg_msg_callback_t func = ppg_get_send_msg_callback_func(); diff --git a/code/sdk/zhihui/drivers/ppg/service/ppg_at_cmd.cpp b/code/sdk/zhihui/drivers/ppg/service/ppg_at_cmd.cpp index de8421c1e..95399656a 100644 --- a/code/sdk/zhihui/drivers/ppg/service/ppg_at_cmd.cpp +++ b/code/sdk/zhihui/drivers/ppg/service/ppg_at_cmd.cpp @@ -10,6 +10,8 @@ #include #include +#include "ppg_hal.h" + #ifdef PPG_VC9202 #include "vc9202_hal.h" #include "vc9202_common.h" @@ -74,10 +76,12 @@ static uint32_t ppg_do_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd) uint32_t md = PPG_SERVICE_CMD_TYPE_DO_PPG_TEST; if (strcmp(mode, "hrs") == 0) { md = PPG_SERVICE_CMD_TYPE_DO_PPG_TEST; + ppg_set_factory_log_switch(1); } else if (strcmp(mode, "hrv") == 0) { md = PPG_SERVICE_CMD_TYPE_DO_HRV_TEST; } else if (strcmp(mode, "spo2") == 0) { md = PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST; + ppg_set_factory_log_switch(1); } else if (strcmp(mode, "leaklight") == 0) { md = PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST; } else if (strcmp(mode, "graycard") == 0) { @@ -90,6 +94,7 @@ static uint32_t ppg_do_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd) if(enabled == 0 ) { + ppg_set_factory_log_switch(0); if (md == PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST) { md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST; diff --git a/code/sdk/zhihui/drivers/vibrator/vibrator_at_cmd.c b/code/sdk/zhihui/drivers/vibrator/vibrator_at_cmd.c index c26d38ae6..6743ef6e0 100644 --- a/code/sdk/zhihui/drivers/vibrator/vibrator_at_cmd.c +++ b/code/sdk/zhihui/drivers/vibrator/vibrator_at_cmd.c @@ -7,6 +7,7 @@ #include "vibrator.h" #include "debug_print.h" #include "vibrator_hal.h" +#include "cmsis_os2.h" #define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0])) #define VIBRATOR_MAX_ARGC 8 @@ -15,6 +16,17 @@ #define VIBRATOR_SUCCESS 0 #define VIBRATOR_FAILED (-1) +// 马达定时器相关变量 +static osTimerId_t g_vibrator_timer = NULL; + +// 马达定时器回调函数 +static void vibrator_timer_callback(void *argument) +{ + UNUSED(argument); + // 执行马达震动 + custom_VibratorFunc_int(0); +} + static int ConvertCmdToParam(uint8_t *para, uint32_t paraLen, uint8_t argv[VIBRATOR_MAX_ARGC][VIBRATOR_MAX_ARGV_LEN], uint32_t* argc) { @@ -68,6 +80,57 @@ static uint32_t vibrator_do_test(uint8_t *para, uint32_t paraLen, char *strCommo hal_custom_VibratorFunc(duty,cycle,duration); return ERRCODE_SUCC; } + +// 马达定时器控制AT指令实现 +static uint32_t vibrator_timer_control(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(strCommonCmd); + uint8_t argv[VIBRATOR_MAX_ARGC][VIBRATOR_MAX_ARGV_LEN] = { 0 }; + uint32_t argc = 0; + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != VIBRATOR_SUCCESS) { + PRINT("VIBRATORTIMER ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + + if (argc != 1) { + PRINT("VIBRATORTIMER ATCMD Set Parameter Failed argc %d, should be AT^VIBRATORTIMER=cmd\n", argc); + return ERRCODE_FAIL; + } + + uint8_t cmd = (uint8_t)atoi((char*)argv[0]); + + if(cmd == 1) + { + if (g_vibrator_timer == NULL) { + g_vibrator_timer = osTimerNew((osTimerFunc_t)vibrator_timer_callback, osTimerPeriodic, NULL, NULL); + } + + if (g_vibrator_timer) { + osTimerStart(g_vibrator_timer, 1000); // 1秒间隔 + PRINT("VIBRATORTIMER ATCMD Start timer with 1s interval\n"); + } else { + PRINT("VIBRATORTIMER ATCMD Create timer failed\n"); + return ERRCODE_FAIL; + } + } + else if(cmd == 0) + { + if (g_vibrator_timer) { + osTimerStop(g_vibrator_timer); + osTimerDelete(g_vibrator_timer); + g_vibrator_timer = NULL; + PRINT("VIBRATORTIMER ATCMD Stop and delete timer\n"); + } + + PRINT("VIBRATORTIMER ATCMD Unknown command %d\n", cmd); + return ERRCODE_FAIL; + } + + return ERRCODE_SUCC; +} + extern errcode_t hal_custom_resume_touch(void); static uint32_t resume_touch(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { @@ -78,8 +141,8 @@ static uint32_t resume_touch(uint8_t *para, uint32_t paraLen, char *strCommonCmd static const at_cmd_table_t g_vibrator_cmd[] = { { (char *)"AT^VIBRATORTEST", vibrator_do_test, (char *)"1" }, + { (char *)"AT^VIBRATORTIMER", vibrator_timer_control, (char *)"1" }, { (char *)"AT^RESUMETOUCH", resume_touch, (char *)"1" }, - }; at_cmd_table_t *get_vibrator_cmd_table(uint32_t *cmd_count) diff --git a/code/sdk/zhihui/services/battery/test/battery_at_cmd.cpp b/code/sdk/zhihui/services/battery/test/battery_at_cmd.cpp index e7cb6dfc8..4038fe7dc 100644 --- a/code/sdk/zhihui/services/battery/test/battery_at_cmd.cpp +++ b/code/sdk/zhihui/services/battery/test/battery_at_cmd.cpp @@ -79,8 +79,26 @@ static uint32_t battery_do_test(uint8_t *para, uint32_t paraLen, char *strCommon return ERRCODE_SUCC; } +static uint32_t battery_get_info(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(para); + UNUSED(paraLen); + UNUSED(strCommonCmd); + + // 获取电池信息:电量、电压、充电状态 + float voltage = 0.0f; + uint8_t percent = batteryservice_get_voltage(&voltage); + uint8_t charge_status = get_charge_stat(); + + printf("BATTERY INFO: Percent=%d%%, Voltage=%.2fV, ChargeStatus=%d\n", + percent, voltage, charge_status); + + return ERRCODE_SUCC; +} + static const at_cmd_table_t g_battery_cmd[] = { { (char *)"AT^CHARGETEST", battery_do_test, (char *)"enable" }, + { (char *)"AT^BATTERYINFO", battery_get_info, (char *)"" }, }; at_cmd_table_t *get_battery_cmd_table(uint32_t *cmd_count) diff --git a/code/sdk/zhihui/utils/custom_utils.c b/code/sdk/zhihui/utils/custom_utils.c index 52354fe18..8c4677be9 100644 --- a/code/sdk/zhihui/utils/custom_utils.c +++ b/code/sdk/zhihui/utils/custom_utils.c @@ -637,6 +637,12 @@ void startup_post_init_task(void) } uapi_gei_btmac_and_chipinfo(); + uint8_t buildversion[128]={0}; + uint16_t versionlen = 128; + uapi_get_buildversion(buildversion,versionlen); + + wstp_print("\nfac:BuildVer:%s\n",buildversion); + uint8_t len = 1; uapi_get_file_data("user/userdata/timestamp_of_day.bin",&day,&len); time(&rawtime); @@ -2994,7 +3000,7 @@ void uapi_gei_btmac_and_chipinfo(void) sprintf((char *)btaddr_str, "%02X:%02X:%02X:%02X:%02X:%02X", btaddr[0], btaddr[1], btaddr[2], btaddr[3], btaddr[4], btaddr[5]); uapi_cywee_get_chipinfo(chipinfo,sizeof(chipinfo)); - wstp_print("^^^^ BTMAC=%s ^^^^ CyweeChipInfo=%s\n",btaddr_str,chipinfo); + wstp_print("fac:^^^^ BTMAC=%s ^^^^ CyweeChipInfo=%s\n",btaddr_str,chipinfo); } uint8_t uapi_get_cywee_active_state(void) diff --git a/code/sdk/zhihui/utils/custom_utils_at_cmd.c b/code/sdk/zhihui/utils/custom_utils_at_cmd.c index 67ff68920..6709e7f60 100644 --- a/code/sdk/zhihui/utils/custom_utils_at_cmd.c +++ b/code/sdk/zhihui/utils/custom_utils_at_cmd.c @@ -7,6 +7,8 @@ #include "custom_utils.h" #include "debug_print.h" #include "custom_runtime.h" +#include "factorytest_protocol.h" +#include "los_base.h" #ifdef SUPPORT_CUSTOM_CONFIG #include "ConfigModelC.h" #endif @@ -82,6 +84,168 @@ static int ConvertCmdToParam(uint8_t *para, uint32_t paraLen, } +// // 表冠测试AT指令实现 +// static uint32_t crown_test_control(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +// { +// UNUSED(strCommonCmd); +// uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = { 0 }; +// uint32_t argc = 0; + +// int ret = ConvertCmdToParam(para, paraLen, argv, &argc); +// if (ret != CUSTOM_UTILS_SUCCESS) { +// wstp_print("CROWNTEST ATCMD Convert Command Failed\n"); +// return ERRCODE_FAIL; +// } + +// if (argc != 1) { +// wstp_print("CROWNTEST ATCMD Set Parameter Failed argc %d, should be AT^CROWNTEST=cmd\n", argc); +// return ERRCODE_FAIL; +// } + +// uint8_t cmd = (uint8_t)atoi((char*)argv[0]); + +// if(cmd == 1) +// { +// uint8_t crown_cmd = 1; +// do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CROWN_TEST, &crown_cmd, sizeof(crown_cmd)); +// wstp_print("CROWNTEST ATCMD Enter crown test interface\n"); + +// } +// else if(cmd == 2) +// { +// uint8_t crown_cmd = 0; +// do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_CROWN_TEST, &crown_cmd, sizeof(crown_cmd)); +// wstp_print("CROWNTEST ATCMD Exit crown test interface\n"); +// } + +// return ERRCODE_SUCC; +// } + +// LCD测试AT指令实现 +static uint32_t lcd_test_control(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(strCommonCmd); + uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = { 0 }; + uint32_t argc = 0; + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != CUSTOM_UTILS_SUCCESS) { + wstp_print("LCDTEST ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + + if (argc != 1) { + wstp_print("LCDTEST ATCMD Set Parameter Failed argc %d, should be AT^LCDTEST=cmd\n", argc); + return ERRCODE_FAIL; + } + + uint8_t cmd = (uint8_t)atoi((char*)argv[0]); + + if(cmd == 1) + { + // 进入LCD测试界面 + uint8_t lcd_cmd = 1; + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_LCD_TEST, &lcd_cmd, sizeof(lcd_cmd)); + wstp_print("LCDTEST ATCMD Enter LCD test interface\n"); + + for(int i = 1; i < 6; i++) + { + LOS_Msleep(2000); + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_LCD_COLOR_TEST, &i, 1); + } + } + else if(cmd == 2) + { + // 退出LCD测试界面 + uint8_t lcd_cmd = 0; + do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_LCD_TEST, &lcd_cmd, sizeof(lcd_cmd)); + wstp_print("LCDTEST ATCMD Exit LCD test interface\n"); + } + // else if(cmd >= 3 && cmd <= 7) + // { + + // // 改变LCD屏幕颜色 + // uint8_t color_cmd = cmd - 2; // 转换为颜色命令 (1-5) + + + // // 根据命令打印对应的颜色信息 + // switch(color_cmd) + // { + // case 1: + // wstp_print("LCDTEST ATCMD Set LCD color: Red\n"); + // break; + // case 2: + // wstp_print("LCDTEST ATCMD Set LCD color: Green\n"); + // break; + // case 3: + // wstp_print("LCDTEST ATCMD Set LCD color: Blue\n"); + // break; + // case 4: + // wstp_print("LCDTEST ATCMD Set LCD color: White\n"); + // break; + // case 5: + // wstp_print("LCDTEST ATCMD Set LCD color: Black\n"); + // break; + // default: + // wstp_print("LCDTEST ATCMD Set LCD color: Unknown\n"); + // break; + // } + // } + // else + // { + // wstp_print("LCDTEST ATCMD Unknown command %d\n", cmd); + // wstp_print("LCDTEST ATCMD Usage:\n"); + // wstp_print(" AT^LCDTEST=1 - Enter LCD test interface\n"); + // wstp_print(" AT^LCDTEST=2 - Exit LCD test interface\n"); + // wstp_print(" AT^LCDTEST=3 - Set LCD color: Red\n"); + // wstp_print(" AT^LCDTEST=4 - Set LCD color: Green\n"); + // wstp_print(" AT^LCDTEST=5 - Set LCD color: Blue\n"); + // wstp_print(" AT^LCDTEST=6 - Set LCD color: White\n"); + // wstp_print(" AT^LCDTEST=7 - Set LCD color: Black\n"); + // return ERRCODE_FAIL; + // } + + return ERRCODE_SUCC; +} + +// // TP测试AT指令实现 +// static uint32_t tp_test_control(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +// { +// UNUSED(strCommonCmd); +// uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = { 0 }; +// uint32_t argc = 0; + +// int ret = ConvertCmdToParam(para, paraLen, argv, &argc); +// if (ret != CUSTOM_UTILS_SUCCESS) { +// wstp_print("TPTEST ATCMD Convert Command Failed\n"); +// return ERRCODE_FAIL; +// } + +// if (argc != 1) { +// wstp_print("TPTEST ATCMD Set Parameter Failed argc %d, should be AT^TPTEST=cmd\n", argc); +// return ERRCODE_FAIL; +// } + +// uint8_t cmd = (uint8_t)atoi((char*)argv[0]); + +// if(cmd == 1) +// { +// // 进入TP测试界面 +// uint8_t tp_cmd = 1; +// do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_TP_TEST, &tp_cmd, sizeof(tp_cmd)); +// wstp_print("TPTEST ATCMD Enter TP test interface\n"); +// } +// else if(cmd == 2) +// { +// // 退出TP测试界面 +// uint8_t tp_cmd = 0; +// do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_TP_TEST, &tp_cmd, sizeof(tp_cmd)); +// wstp_print("TPTEST ATCMD Exit TP test interface\n"); +// } + +// return ERRCODE_SUCC; +// } + static uint32_t custom_utils_setsn(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { UNUSED(strCommonCmd); @@ -1397,7 +1561,99 @@ static uint32_t custom_at_gpio(uint8_t *para, uint32_t paraLen, char *strCommonC return ERRCODE_SUCC; } +static uint32_t custom_factory_bt_test_start(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(strCommonCmd); + + custom_factory_bt_scan_start(); + + return ERRCODE_SUCC; +} + +static uint32_t custom_factory_bt_test_stop(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(strCommonCmd); + + custom_factory_bt_scan_stop(); + + return ERRCODE_SUCC; +} + +// 录音相关AT指令实现 +static uint32_t custom_audio_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(strCommonCmd); + uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = { 0 }; + uint32_t argc = 0; + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != CUSTOM_UTILS_SUCCESS) { + wstp_print("AUDIO TEST ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + + if (argc != 1) { + wstp_print("AUDIO TEST ATCMD Set Parameter Failed argc %d\n", argc); + wstp_print("Usage: AT^AUDIOTEST=cmd\n"); + wstp_print(" cmd: 1=start record, 2=stop record, 3=start play, 4=stop play\n"); + return ERRCODE_FAIL; + } + + uint8_t cmd = (uint8_t)atoi((char*)argv[0]); + + switch (cmd) { + case 1: // 开始录音 + { + errcode_t ret = do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_START_MIC, NULL, 0); + if (ret == ERRCODE_SUCC) { + wstp_print("AUDIO RECORD START: Success (Queued)\n"); + } else { + wstp_print("AUDIO RECORD START: Failed, ret=%d\n", ret); + } + } + break; + case 2: // 停止录音 + { + errcode_t ret = do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_STOP_MIC, NULL, 0); + if (ret == ERRCODE_SUCC) { + wstp_print("AUDIO RECORD STOP: Success (Queued)\n"); + } else { + wstp_print("AUDIO RECORD STOP: Failed, ret=%d\n", ret); + } + } + break; + case 3: // 开始播放 + { + errcode_t ret = do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_START_CHECK_MIC, NULL, 0); + if (ret == ERRCODE_SUCC) { + wstp_print("AUDIO PLAY START: Success (Queued)\n"); + } else { + wstp_print("AUDIO PLAY START: Failed, ret=%d\n", ret); + } + } + break; + case 4: // 停止播放并删除录音 + { + errcode_t ret = do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_STOP_CHECK_MIC, NULL, 0); + if (ret == ERRCODE_SUCC) { + wstp_print("AUDIO PLAY STOP: Success (Queued)\n"); + // 停止播放后自动删除录音文件 + // uapi_delete_files("/user/userdata/microphone.mp3"); + wstp_print("AUDIO RECORD DELETE: Success\n"); + } else { + wstp_print("AUDIO PLAY STOP: Failed, ret=%d\n", ret); + } + } + break; + default: + wstp_print("AUDIO TEST ATCMD Unknown command %d\n", cmd); + wstp_print("Usage: AT^AUDIOTEST=cmd\n"); + wstp_print(" cmd: 1=start record, 2=stop record, 3=start play, 4=stop play\n"); + return ERRCODE_FAIL; + } + return ERRCODE_SUCC; +} static const at_cmd_table_t g_custom_utils_cmd[] = { { (char *)"AT^CUSTOM_SN", custom_utils_setsn, (char *)"123456789ABCDEF2345678" }, @@ -1490,6 +1746,14 @@ static const at_cmd_table_t g_custom_utils_cmd[] = { { (char *)"AT^AUTOOTACHECK", send_check_ota_atuoota, (char *)" " }, { (char *)"AT^POWEROFF", custom_at_poweroff, (char *)" " }, { (char *)"AT^GPIO", custom_at_gpio, (char *)" " }, + // { (char *)"AT^CROWNKEYTEST", crown_test_control, (char *)" " }, + { (char *)"AT^LCDTEST", lcd_test_control, (char *)" " }, + // { (char *)"AT^TPTEST", tp_test_control, (char *)" " }, + { (char *)"AT^BTTESTSTART", custom_factory_bt_test_start, (char *)" " }, + { (char *)"AT^BTTESTSTOP", custom_factory_bt_test_stop, (char *)" " }, + + // 录音相关AT指令 + { (char *)"AT^AUDIOTEST", custom_audio_test, (char *)" " }, }; diff --git a/code/sdk/zhihui/utilscpp/custom_utilscpp.cpp b/code/sdk/zhihui/utilscpp/custom_utilscpp.cpp index 18402bb0f..e99ead7a8 100644 --- a/code/sdk/zhihui/utilscpp/custom_utilscpp.cpp +++ b/code/sdk/zhihui/utilscpp/custom_utilscpp.cpp @@ -22,6 +22,17 @@ #include "audio_manager.h" #include "audio_base_type.h" + +#include "bts_br_gap.h" +#include "bts_le_gap.h" + +#ifdef SUPPORT_BLE_SERVICE +#include "bleService.h" +#endif + +#include "bluetooth/include/BluetoothModel.h" + + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -71,6 +82,7 @@ extern "C" { #define IN_BUF_SIZE (1 << 8) #define OUT_BUF_SIZE (1 << 8) +static osTimerId_t g_bt_scan_timer = NULL; static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 unpackSize) @@ -354,4 +366,81 @@ errcode_t post_func_to_graphic(void (*func)(void)) #ifdef __cplusplus } -#endif /* __cplusplus */ \ No newline at end of file +#endif /* __cplusplus */ + + +static void custom_factory_bt_scan_callback(void) +{ +#ifdef SUPPORT_BLE_SERVICE + std::list btScansDevicesList_ = OHOS::BluetoothModel::GetInstance()->GetCase(); + std::list::iterator node = btScansDevicesList_.begin(); + if (btScansDevicesList_.empty()) { + printf("btScansDevicesList_.empty()\n"); + return; + } + + int i = 0; + + while (node != btScansDevicesList_.end()) { + i++; + printf("fac:device[%d]:name %s, addr:%02X %02X %02X %02X %02X %02X Rssi:%d\n", + i,node->deviceName,node->addr[0],node->addr[1],node->addr[2],node->addr[3],node->addr[4],node->addr[5],node->temp); + + OHOS::BluetoothModel::GetInstance()->SortScansCaseRssi(); + node++; + } +#endif +} + +void custom_factory_bt_scan_start(void) +{ + if (g_bt_scan_timer == NULL) { + g_bt_scan_timer = osTimerNew((osTimerFunc_t)custom_factory_bt_scan_callback, osTimerPeriodic, NULL, NULL); + } + + if (g_bt_scan_timer) { + osTimerStart(g_bt_scan_timer, 2000); // 1秒间隔 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "custom_factory_bt_scan_start!"); + } +#ifdef SUPPORT_BLE_SERVICE + #ifdef BLE_scan + srv_ble_start_scan(); + #else + uint32_t device_classes = + DEVICE_MAJOR_CLASS_AUDIO_VIDEO|DEVICE_MAJOR_CLASS_PHONE|SERVICE_AUDIO + |SERVICE_LIMITED_DISCOVERABILITY|SERVICE_POSITIONING|SERVICE_NETWORKING + |SERVICE_RENDER|SERVICE_CAPTURE|SERVICE_OBJECT_TRANSFER|SERVICE_TELEPHONY + |SERVICE_INFORMATION; + // errcode_t err = gap_br_set_inquiry_paramters(device_classes, 5); + errcode_t err = gap_br_set_inquiry_paramters(0,20); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"gap_br_set_inquiry_paramters errcode_t %d!\n",err); + + bool ret = gap_br_start_discovery(); + OHOS::BluetoothModel::GetInstance()->SortScansCaseRssi(); + #ifdef FD230 + OHOS::BluetoothModel::GetInstance()->set_test_bt_falg(true); + #endif + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"gap_br_start_discovery bool %d!\n",ret); + #endif +#endif +} + +void custom_factory_bt_scan_stop(void) +{ + if (g_bt_scan_timer) { + osTimerStop(g_bt_scan_timer); + osTimerDelete(g_bt_scan_timer); + g_bt_scan_timer = NULL; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "custom_factory_bt_scan_stop!"); + } +#ifdef SUPPORT_BLE_SERVICE + #ifdef BLE_scan + srv_ble_stop_scan(); + #else + bool ret = gap_br_cancel_discovery(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"gap_br_cancel_discovery bool %d!\n",ret); + + #endif +#endif +} \ No newline at end of file diff --git a/code/sdk/zhihui/utilscpp/custom_utilscpp.h b/code/sdk/zhihui/utilscpp/custom_utilscpp.h index cf9732347..74c5db69a 100644 --- a/code/sdk/zhihui/utilscpp/custom_utilscpp.h +++ b/code/sdk/zhihui/utilscpp/custom_utilscpp.h @@ -1,8 +1,8 @@ /* * @Author: penglei 1624952103@qq.com * @Date: 2024-07-09 20:22:54 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-09-27 09:40:39 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-08-20 15:13:20 * @FilePath: /FD230/code/sdk/drivers/peripheral/utilscpp/custom_utilscpp.h * @Description: * @@ -31,6 +31,8 @@ void CustomEventPublish(uint16_t topic, uint8_t *data , uint32_t size); void custom_set_volume(uint8_t channel,int32_t sounding); +void custom_factory_bt_scan_start(void); +void custom_factory_bt_scan_stop(void); /** * input: -- 2.17.1