From 32b20c85adf783effd7d40d146a2670013880a19 Mon Sep 17 00:00:00 2001 From: helloyifa <447523396@qq.com> Date: Fri, 18 Jul 2025 16:33:00 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9B=B4=E6=96=B0=E5=BC=80=E6=9C=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91=202.=E4=BF=AE=E5=A4=8D=E5=BC=80=E6=9C=BALED=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=B8=B8=E4=BA=AE=E6=97=B6=E5=BC=80=E6=9C=BA=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bk_websocket/bk_websocket_client.c | 18 +- .../bk_factory_config/bk_factory_config.c | 4 + .../projects/beken_wss_paopao/main/app_main.c | 399 ++++++++---------- .../main/boarding_service/boarding_core.c | 9 +- .../boarding_service/wifi_boarding_utils.c | 3 +- .../projects/beken_wss_paopao/main/spi_led.c | 31 +- 6 files changed, 228 insertions(+), 236 deletions(-) diff --git a/bk_aidk/bk_avdk/bk_idk/components/bk_websocket/bk_websocket_client.c b/bk_aidk/bk_avdk/bk_idk/components/bk_websocket/bk_websocket_client.c index fc537717..cd0048f3 100755 --- a/bk_aidk/bk_avdk/bk_idk/components/bk_websocket/bk_websocket_client.c +++ b/bk_aidk/bk_avdk/bk_idk/components/bk_websocket/bk_websocket_client.c @@ -818,10 +818,10 @@ static int ws_connect(transport client, const char *host, int port, int timeout_ } header_len += len; ws->buffer[header_len] = '\0'; - BK_LOGE(TAG, "Read header chunk %d, current header size: %d\r\n", len, header_len); + BK_LOGD(TAG, "Read header chunk %d, current header size: %d\r\n", len, header_len); } while (NULL == os_strstr(ws->buffer, "\r\n\r\n") && header_len < WS_BUFFER_SIZE); - os_printf("server buffer:\r\n"); - bk_hex_dump(ws->buffer, 200); + //os_printf("server buffer:\r\n"); + //bk_hex_dump(ws->buffer, 200); #if 0 if (header_len == WS_BUFFER_SIZE) { char *is_chunk = get_http_header(ws->buffer, "Transfer-Encoding:"); @@ -853,9 +853,9 @@ static int ws_connect(transport client, const char *host, int port, int timeout_ } mbedtls_base64_encode(expected_server_key, sizeof(expected_server_key), &outlen, expected_server_sha1, sizeof(expected_server_sha1)); expected_server_key[ (outlen < sizeof(expected_server_key)) ? outlen : (sizeof(expected_server_key) - 1) ] = 0; - BK_LOGE(TAG, "server key=%s\r\n\r\n", (char *)server_key); - BK_LOGE(TAG, "send_key=%s\r\n\r\n", (char*)client_key); - BK_LOGE(TAG, "expected_server_key=%s\r\n\r\n", expected_server_key); + BK_LOGD(TAG, "server key=%s\r\n\r\n", (char *)server_key); + BK_LOGD(TAG, "send_key=%s\r\n\r\n", (char*)client_key); + BK_LOGD(TAG, "expected_server_key=%s\r\n\r\n", expected_server_key); if (os_strcmp((char*)expected_server_key, (char*)server_key) != 0) { BK_LOGE(TAG, "Invalid websocket key\r\n"); return BK_FAIL; @@ -1082,7 +1082,7 @@ bk_err_t websocket_client_set_uri(transport client, const char *uri) } os_strncpy(client->config->scheme, uri + puri.field_data[UF_SCHEMA].off, puri.field_data[UF_SCHEMA].len); //client->config->scheme[puri.field_data[UF_SCHEMA].len] = '\0'; - os_printf("%s scheme:%s len:%d\r\n", __func__, client->config->scheme, puri.field_data[UF_SCHEMA].len); + //os_printf("%s scheme:%s len:%d\r\n", __func__, client->config->scheme, puri.field_data[UF_SCHEMA].len); } if (puri.field_data[UF_HOST].len) { @@ -1346,7 +1346,7 @@ void websocket_client_task(beken_thread_arg_t *thread_param) while (client->run) { switch ((int)client->state) { case WEBSOCKET_STATE_INIT: - BK_LOGE(TAG, "websocket connecting to %s://%s:%d\r\n", client->config->scheme, client->config->host, client->config->port); + BK_LOGD(TAG, "websocket connecting to %s://%s:%d\r\n", client->config->scheme, client->config->host, client->config->port); if (ws_connect(client, client->config->host, client->config->port, WEBSOCKET_NETWORK_TIMEOUT_MS) < 0) { @@ -1354,7 +1354,7 @@ void websocket_client_task(beken_thread_arg_t *thread_param) ws_disconnect(client); break; } - BK_LOGE(TAG, "websocket connected to %s://%s:%d\r\n", client->config->scheme, client->config->host, client->config->port); + BK_LOGD(TAG, "websocket connected to %s://%s:%d\r\n", client->config->scheme, client->config->host, client->config->port); client->state = WEBSOCKET_STATE_CONNECTED; client->wait_for_pong_resp = false; bk_websocket_client_dispatch_event(client, WEBSOCKET_EVENT_CONNECTED, NULL, 0, -1); diff --git a/bk_aidk/components/bk_factory_config/bk_factory_config.c b/bk_aidk/components/bk_factory_config/bk_factory_config.c index 1df3b823..b00e5aaf 100644 --- a/bk_aidk/components/bk_factory_config/bk_factory_config.c +++ b/bk_aidk/components/bk_factory_config/bk_factory_config.c @@ -31,6 +31,8 @@ static const uint32_t s_factory_volume = 7; static const uint32_t s_bat_offset = 0; +static const uint32_t s_bright_timeout = 10; +static const uint32_t s_bright_brightness = 100; const struct factory_config_t s_platform_config[] = { {"sys_initialized", (void *)"1", 1, BK_FALSE, 1}, // first config used to check whether factory config initialized. @@ -40,6 +42,8 @@ const struct factory_config_t s_platform_config[] = { {"bat_offset", (void *)&s_bat_offset, 4, BK_TRUE, 4}, {"ai_ota_url", (void *)"\0", 1, BK_TRUE, 128}, {"ai_agent_id", (void *)"\0", 1, BK_TRUE, 128}, + {"bright_timeout", (void *)&s_bright_timeout, 4, BK_TRUE, 4}, + {"bright_brightness", (void *)&s_bright_brightness, 4, BK_TRUE, 4}, }; static const struct factory_config_t *s_user_reg_config = NULL; diff --git a/bk_aidk/projects/beken_wss_paopao/main/app_main.c b/bk_aidk/projects/beken_wss_paopao/main/app_main.c index 20a3dc93..05a31f28 100755 --- a/bk_aidk/projects/beken_wss_paopao/main/app_main.c +++ b/bk_aidk/projects/beken_wss_paopao/main/app_main.c @@ -103,6 +103,8 @@ const struct factory_config_t s_user_config[] = { #if (CONFIG_SYS_CPU0) #include "iot/thing.h" #endif +void power_on(); +void power_off(); static int beken_rtc_cli_init(void) { @@ -140,31 +142,55 @@ void prepare_config_network_main() config_network_thread_handle = NULL; rtos_delete_thread(NULL); } - - - -void power_off() +beken_timer_t g_adckey_timer; +static void adc_key_ticks(void *param) { - BK_LOGI(TAG, " power_off\r\n"); - BK_LOGW(TAG, " ************TODO:Just force deep sleep for Demo!\r\n"); - // extern bk_err_t audio_turn_off(void); - // extern bk_err_t video_turn_off(void); - // audio_turn_off(); - // video_turn_off(); - //zhanyu - // bk_reboot_ex(RESET_SOURCE_FORCE_DEEPSLEEP); -} + bk_printf("adc_key_ticks9\n"); -void power_on() -{ - BK_LOGI(TAG, "power_on\r\n"); -} +#if (CONFIG_SYS_CPU0) + gsensor_demo_init(); + // rtos_delay_milliseconds(100); + // gsensor_demo_open(); + rtos_delay_milliseconds(300); + gsensor_demo_set_normal(); +#endif -void ai_agent_config() -{ - // BK_LOGW(TAG, " ************TODO:AI Agent doesn't complete!\r\n"); + rtos_stop_timer(&g_adckey_timer); + + rtos_deinit_timer(&g_adckey_timer); } +KeyConfig_t key_config[] = { + // zhanyu + + { + .gpio_id = KEY_GPIO_12, + .active_level = LOW_LEVEL_TRIGGER, + .short_event = POWER_ON, + //.double_event = TURN_ON_LOGHT, + .long_event = TURN_OFF_LOGHT} + // { + // .gpio_id = KEY_GPIO_13, //corresponding to the actual key + // .active_level = LOW_LEVEL_TRIGGER, + // .short_event = VOLUME_UP, + // .double_event = VOLUME_UP, //TRICK: at shutdown mode, it can't recognize double press,short_event is really power on.(but short event is used by VOLUME UP when system is active). + // .long_event = CONFIG_NETWORK + // }, + // { + // .gpio_id = KEY_GPIO_12, + // .active_level = LOW_LEVEL_TRIGGER, + // .short_event = POWER_ON, + // .double_event = POWER_ON, + // .long_event = SHUT_DOWN + // }, + // { + // .gpio_id = KEY_GPIO_8, + // .active_level = LOW_LEVEL_TRIGGER, + // .short_event = VOLUME_DOWN, + // .double_event = VOLUME_DOWN, + // .long_event = FACTORY_RESET + // } +}; /*Do not execute blocking or time-consuming long code in event handler functions. The reason is that key_thread processes messages in a @@ -176,30 +202,7 @@ static void handle_system_event(key_event_t event) extern void bk_bt_app_avrcp_ct_vol_change(uint32_t platform_vol); switch (event) { -// case VOLUME_UP: -// { -// uint32_t old_volume = volume; -// volume_increase(); -// if (old_volume != volume) -// { -// #if CONFIG_A2DP_SINK_DEMO -// bk_bt_app_avrcp_ct_vol_change(volume); -// #endif -// } -// } -// break; -// case VOLUME_DOWN: -// { -// uint32_t old_volume = volume; -// volume_decrease(); -// if (old_volume != volume) -// { -// #if CONFIG_A2DP_SINK_DEMO -// bk_bt_app_avrcp_ct_vol_change(volume); -// #endif -// } -// } -// break; + // case SHUT_DOWN: // time = rtos_get_time(); // long press more than 6s // if (time < 9000) @@ -235,13 +238,16 @@ static void handle_system_event(key_event_t event) // bk_factory_reset(); // bk_reboot(); // break; + case POWER_ON: + bk_printf("POWER_KEY PRESS\n"); + break; case TURN_OFF_LOGHT: - bk_printf("ispoweron11 = %d\n", ispoweron); + bk_printf("current is power on = %d\n", ispoweron); // clearallled(); if (ispoweron == 1) { - bk_printf("POWER OFFaaa~~~ \r\n"); + bk_printf("POWER OFF!!\r\n"); poweroff_voice(); ws2812_led_clear_all(); ispoweron = 0; @@ -252,9 +258,10 @@ static void handle_system_event(key_event_t event) } else if (ispoweron == 0) { - bk_printf("POWER ONaaaa~~~~~~~\r\n"); - + bk_printf("POWER ON \r\n"); + power_on(); #if (CONFIG_SYS_CPU0) + //打开电源供电 bk_gpio_enable_output(51); bk_gpio_set_output_high(51); ispoweron = 1; @@ -270,57 +277,137 @@ static void handle_system_event(key_event_t event) default: break; } + } + +void power_off() +{ + BK_LOGE(TAG, " power_off\r\n"); + BK_LOGW(TAG, " ************TODO:Just force deep sleep for Demo!\r\n"); + // extern bk_err_t audio_turn_off(void); + // extern bk_err_t video_turn_off(void); + // audio_turn_off(); + // video_turn_off(); + + //zhanyu + // bk_reboot_ex(RESET_SOURCE_FORCE_DEEPSLEEP); +} + +void power_on() +{ + BK_LOGE(TAG, "power_on!!!!!!\r\n"); +#if (CONFIG_SYS_CPU0) + bk_regist_factory_user_config((const struct factory_config_t *)&s_user_config, + sizeof(s_user_config) / sizeof(s_user_config[0])); + bk_factory_init(); +#endif + // led init move before +#if (CONFIG_SYS_CPU0) + + // No operation countdown 3 minutes to shut down + // start_countdown(countdown_ms); + // led init move before + led_driver_init(); + led_app_set(LED_ON_GREEN, LED_LAST_FOREVER); + +#endif + // media_service_init(); + +#if (CONFIG_SYS_CPU0) + //app_event_init(); + +#if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE + extern bk_err_t audio_turn_on(void); + int ret = audio_turn_on(); + if (ret != BK_OK) + { + BK_LOGE(TAG, "%s, %d, audio turn on fail, ret:%d\n", __func__, __LINE__, ret); + } +#endif +#endif + +#if (CONFIG_SYS_CPU1) + beken_rtc_cli_init(); +#endif + +#if (CONFIG_SYS_CPU0) + bk_pm_module_vote_boot_cp1_ctrl(PM_BOOT_CP1_MODULE_NAME_AUDP_AUDIO, PM_POWER_MODULE_STATE_ON); + + bk_genie_core_init(); + +#if CONFIG_NETWORK_AUTO_RECONNECT + bk_genie_smart_config_init(); +#endif + + + +#if CONFIG_BAT_MONITOR + extern void battery_monitor_init(void); + battery_monitor_init(); +#endif + + bk_err_t result; + + result = rtos_init_timer(&g_adckey_timer, + 6000, + adc_key_ticks, + (void *)0); + + if (result != 0) + { + bk_printf("rtos_init_timer fail\r\n"); } - KeyConfig_t key_config[] = { - // zhanyu - - { - .gpio_id = KEY_GPIO_12, - .active_level = LOW_LEVEL_TRIGGER, - //.short_event = TURN_ON_LOGHT, - //.double_event = TURN_ON_LOGHT, - .long_event = TURN_OFF_LOGHT} - // { - // .gpio_id = KEY_GPIO_13, //corresponding to the actual key - // .active_level = LOW_LEVEL_TRIGGER, - // .short_event = VOLUME_UP, - // .double_event = VOLUME_UP, //TRICK: at shutdown mode, it can't recognize double press,short_event is really power on.(but short event is used by VOLUME UP when system is active). - // .long_event = CONFIG_NETWORK - // }, - // { - // .gpio_id = KEY_GPIO_12, - // .active_level = LOW_LEVEL_TRIGGER, - // .short_event = POWER_ON, - // .double_event = POWER_ON, - // .long_event = SHUT_DOWN - // }, - // { - // .gpio_id = KEY_GPIO_8, - // .active_level = LOW_LEVEL_TRIGGER, - // .short_event = VOLUME_DOWN, - // .double_event = VOLUME_DOWN, - // .long_event = FACTORY_RESET - // } - }; - - static void bk_key_register_wakeup_source() + result = rtos_start_timer(&g_adckey_timer); + if (result != 0) { - for (uint8_t i = 0; i < sizeof(key_config) / sizeof(KeyConfig_t); i++) + bk_printf("rtos_start_timer fail\r\n"); + } + +#if (CONFIG_SYS_CPU0) + // bk_printf("ispoweron = %d bk_enter_deepsleep();\n",ispoweron); + // if(ispoweron == 0){ + // bk_printf("bk_enter_deepsleep()aaa\n"); + // bk_enter_deepsleep(); + // } + + // poka + ws2812_init(); + thing_init(); + app_start(); + init_bat_timer(); + // spi_led_init(); + bk_printf("VER:%s\r\n", APPLICATION_VERSION); +#endif +#endif + +#if CONFIG_USBD_MSC + extern void msc_storage_init(void); + msc_storage_init(); +#endif +} + +void ai_agent_config() +{ + // BK_LOGW(TAG, " ************TODO:AI Agent doesn't complete!\r\n"); +} + +static void bk_key_register_wakeup_source() +{ + for (uint8_t i = 0; i < sizeof(key_config) / sizeof(KeyConfig_t); i++) + { + if ((key_config[i].short_event == POWER_ON) || (key_config[i].double_event == POWER_ON) || (key_config[i].long_event == POWER_ON)) { - if ((key_config[i].short_event == POWER_ON) || (key_config[i].double_event == POWER_ON) || (key_config[i].long_event == POWER_ON)) + if (key_config[i].active_level == LOW_LEVEL_TRIGGER) { - if (key_config[i].active_level == LOW_LEVEL_TRIGGER) - { - bk_gpio_register_wakeup_source(key_config[i].gpio_id, GPIO_INT_TYPE_FALLING_EDGE); - } - else - { - bk_gpio_register_wakeup_source(key_config[i].gpio_id, GPIO_INT_TYPE_RISING_EDGE); - } + bk_gpio_register_wakeup_source(key_config[i].gpio_id, GPIO_INT_TYPE_FALLING_EDGE); + } + else + { + bk_gpio_register_wakeup_source(key_config[i].gpio_id, GPIO_INT_TYPE_RISING_EDGE); } } } + } static bk_err_t app_force_analog_ldo_gpio_close() { /*audio*/ @@ -406,29 +493,10 @@ static void handle_system_event(key_event_t event) { #if (CONFIG_SYS_CPU0) bk_pm_module_vote_cpu_freq(PM_DEV_ID_AUDIO, PM_CPU_FRQ_240M); - - beken_rtc_cli_init(); + //beken_rtc_cli_init(); #endif } - beken_timer_t g_adckey_timer; - - static void adc_key_ticks(void *param) - { - - bk_printf("adc_key_ticks9\n"); - -#if (CONFIG_SYS_CPU0) - gsensor_demo_init(); - // rtos_delay_milliseconds(100); - // gsensor_demo_open(); - rtos_delay_milliseconds(300); - gsensor_demo_set_normal(); -#endif - - rtos_stop_timer(&g_adckey_timer); - - rtos_deinit_timer(&g_adckey_timer); - } + int main(void) { @@ -438,9 +506,6 @@ static void handle_system_event(key_event_t event) bk_gpio_enable_output(GPIO_0); bk_gpio_set_output_low(GPIO_0); - - - if (bk_misc_get_reset_reason() != RESET_SOURCE_FORCE_DEEPSLEEP) { #if (CONFIG_SYS_CPU0) @@ -448,6 +513,9 @@ static void handle_system_event(key_event_t event) #endif bk_init(); + media_service_init(); + + #if (CONFIG_SYS_CPU0) #ifdef CONFIG_LDO3V3_ENABLE BK_LOG_ON_ERR(gpio_dev_unmap(LDO3V3_CTRL_GPIO)); @@ -455,113 +523,12 @@ static void handle_system_event(key_event_t event) bk_gpio_enable_output(LDO3V3_CTRL_GPIO); bk_gpio_set_output_high(LDO3V3_CTRL_GPIO); #endif -#endif - -#if (CONFIG_SYS_CPU0) - - - /*to judgement key is long press or short press; long press exit deepsleep*/ - - //zhanyu - // if (bk_misc_get_reset_reason() == RESET_SOURCE_DEEPPS_GPIO && (bk_gpio_get_wakeup_gpio_id() == KEY_GPIO_12)) - // { - // // motor vibration - // motor_open(PWM_MOTOR_CH_3); - // bk_wait_power_on(); - // motor_close(PWM_MOTOR_CH_3); - // } - - bk_regist_factory_user_config((const struct factory_config_t *)&s_user_config, - sizeof(s_user_config) / sizeof(s_user_config[0])); - bk_factory_init(); -#endif - -// led init move before -#if (CONFIG_SYS_CPU0) - - // No operation countdown 3 minutes to shut down - // start_countdown(countdown_ms); - // led init move before - led_driver_init(); - led_app_set(LED_ON_GREEN, LED_LAST_FOREVER); - -#endif - media_service_init(); - -#if (CONFIG_SYS_CPU0) app_event_init(); - -#if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE - extern bk_err_t audio_turn_on(void); - int ret = audio_turn_on(); - if (ret != BK_OK) - { - BK_LOGE(TAG, "%s, %d, audio turn on fail, ret:%d\n", __func__, __LINE__, ret); - } -#endif -#endif - -#if (CONFIG_SYS_CPU1) - beken_rtc_cli_init(); -#endif - -#if (CONFIG_SYS_CPU0) - bk_pm_module_vote_boot_cp1_ctrl(PM_BOOT_CP1_MODULE_NAME_AUDP_AUDIO, PM_POWER_MODULE_STATE_ON); - - bk_genie_core_init(); - -#if CONFIG_NETWORK_AUTO_RECONNECT - bk_genie_smart_config_init(); -#endif - register_event_handler(handle_system_event); bk_key_driver_init(key_config, sizeof(key_config) / sizeof(KeyConfig_t)); -#if CONFIG_BAT_MONITOR - extern void battery_monitor_init(void); - battery_monitor_init(); #endif - - bk_err_t result; - - result = rtos_init_timer(&g_adckey_timer, - 6000, - adc_key_ticks, - (void *)0); - - if (result != 0) - { - bk_printf("rtos_init_timer fail\r\n"); - } - - result = rtos_start_timer(&g_adckey_timer); - if (result != 0) - { - bk_printf("rtos_start_timer fail\r\n"); - } - -#if (CONFIG_SYS_CPU0) -// bk_printf("ispoweron = %d bk_enter_deepsleep();\n",ispoweron); -// if(ispoweron == 0){ -// bk_printf("bk_enter_deepsleep()aaa\n"); -// bk_enter_deepsleep(); -// } - - //poka - ws2812_init(); - thing_init(); - app_start(); - init_bat_timer(); - // spi_led_init(); - bk_printf("VER:%s\r\n",APPLICATION_VERSION); -#endif -#endif - -#if CONFIG_USBD_MSC - extern void msc_storage_init(void); - msc_storage_init(); -#endif } else { diff --git a/bk_aidk/projects/beken_wss_paopao/main/boarding_service/boarding_core.c b/bk_aidk/projects/beken_wss_paopao/main/boarding_service/boarding_core.c index fd59f66b..2f99235e 100755 --- a/bk_aidk/projects/beken_wss_paopao/main/boarding_service/boarding_core.c +++ b/bk_aidk/projects/beken_wss_paopao/main/boarding_service/boarding_core.c @@ -65,11 +65,11 @@ bk_err_t bk_genie_send_msg(bk_genie_msg_t *msg) //helloyifa //static wifi_scan_result_t *scan_result = NULL; static wifi_scan_result_t scan_result = {0}; -static wifi_scan_ap_info_t aps_tmps[15]; +static wifi_scan_ap_info_t aps_tmps[20]; int ssid_count_in_scan_result(char * ssid){ int count = 0; - for(int i = 0 ;i<15 ;i++){ + for(int i = 0 ;i<20 ;i++){ if (strcmp(ssid, aps_tmps[i].ssid) == 0) { //printf("�����ַ������\n"); @@ -107,11 +107,10 @@ void ble_set_wifi_scan_result(wifi_scan_result_t *result){ if (strlen(scan_result->aps[i].ssid) > 0) { // os_printf("WIFI_SCAN:%s\r\n",scan_result->aps[i].ssid); - // �ж��Ƿ����ӹ������� if (ssid_count_in_scan_result(scan_result->aps[i].ssid) > 0) { - // os_printf("%s alread in list\r\n",scan_result->aps[i].ssid); - continue; + os_printf("%s alread in list\r\n",scan_result->aps[i].ssid); + //continue; } // ���浽�б� diff --git a/bk_aidk/projects/beken_wss_paopao/main/boarding_service/wifi_boarding_utils.c b/bk_aidk/projects/beken_wss_paopao/main/boarding_service/wifi_boarding_utils.c index 2f8903b0..5a2d75e7 100755 --- a/bk_aidk/projects/beken_wss_paopao/main/boarding_service/wifi_boarding_utils.c +++ b/bk_aidk/projects/beken_wss_paopao/main/boarding_service/wifi_boarding_utils.c @@ -192,11 +192,12 @@ static uint16_t *const s_boarding_attr_handle_list[sizeof(s_gatts_attr_db_servic }; static boarding_state m_state = BOARDING_STATE_IDLE; int ble_notify_boarding_state(boarding_state state){ + wboard_logi("ble_notify_boarding_state: %d \n", state); if(m_state == state){ return 0; } //在没有配置wifi情况下,不发送状态AP_NOFOUND PASSWORD_ERROR - if(state== BOARDING_STATE_AP_NOFOUND && m_state != BOARDING_STATE_SETWIFI){ + if(state== BOARDING_STATE_AP_NOFOUND && m_state == BOARDING_STATE_SETWIFI){ return 0; } if(state== BOARDING_STATE_PASSWORD_ERROR && m_state != BOARDING_STATE_SETWIFI){ diff --git a/bk_aidk/projects/beken_wss_paopao/main/spi_led.c b/bk_aidk/projects/beken_wss_paopao/main/spi_led.c index 1a6ae55c..2e51c42a 100755 --- a/bk_aidk/projects/beken_wss_paopao/main/spi_led.c +++ b/bk_aidk/projects/beken_wss_paopao/main/spi_led.c @@ -329,6 +329,7 @@ void ws2812_init(){ int close_led_timeout = APPLICATION_DEFULT_LIGHT_TIMEOUT; ret = bk_get_env_enhance(WS2812_CONFIG_BRIGHT_TIMEOUT, (void *)&close_led_timeout, 4); bk_printf("bk_get_env_enhance close_led_timeout:%d\n",close_led_timeout); + work_timeout = close_led_timeout*60*1000; int brightness = APPLICATION_DEFULT_LIGHT_BRIGHTNESS; @@ -337,8 +338,11 @@ void ws2812_init(){ current_brightness = brightness; #endif bk_printf("ws2812 init work_timeout:%d ms\n",work_timeout); - //初始化定时器 - rtos_init_timer(&timer_close_handle, work_timeout, ws2812_close_timer_handle, 0); + if(work_timeout > 0){ + //初始化定时器 + rtos_init_timer(&timer_close_handle, work_timeout, ws2812_close_timer_handle, 0); + } + } void ws2812_deinit(){ @@ -481,18 +485,31 @@ int ws2812_get_brightness(){ * 启动定时关闭 */ void ws2812_start_timer(){ + bk_printf("ws2812_reload_timer: %d ms\n",work_timeout); //超时自动关闭 rtos_start_timer(&timer_close_handle); } void ws2812_reload_timer(){ - //复位定时器 - rtos_reload_timer(&timer_close_handle); + bk_printf("ws2812_reload_timer: %d ms\n",work_timeout); + + if(work_timeout > 0){ + if(!rtos_is_timer_init(&timer_close_handle)){ + rtos_init_timer(&timer_close_handle, work_timeout, ws2812_close_timer_handle, 0); + } + bk_printf("ws2812_reload_time1r: %d ms\n",work_timeout); + if(rtos_is_timer_init(&timer_close_handle) && rtos_is_timer_running(&timer_close_handle)){ + //复位定时器 + rtos_reload_timer(&timer_close_handle); + } + } + + } void ws2812_close_timer(){ - if(rtos_is_timer_init(&timer_close_handle) || rtos_is_timer_running(&timer_close_handle)){ + if(rtos_is_timer_init(&timer_close_handle) && rtos_is_timer_running(&timer_close_handle)){ rtos_stop_timer(&timer_close_handle); } } @@ -505,6 +522,10 @@ void ws2812_set_timeout(int timeout_m){ bk_printf("ws2812_set_timeout: %d ms\n",work_timeout); if(work_timeout > 0){ + + if(!rtos_is_timer_init(&timer_close_handle)){ + rtos_init_timer(&timer_close_handle, work_timeout, ws2812_close_timer_handle, 0); + } rtos_change_period(&timer_close_handle, work_timeout); ws2812_reload_timer(); }else{