修改产测逻辑。循环进行测试,先进行wifi测试,再进行亮灯测试,亮灯一直循环
This commit is contained in:
@@ -30,7 +30,7 @@ extern "C" {
|
||||
|
||||
#define DEVICE_HIVERSION "1.0.0"
|
||||
/* 设备固件版本号 */
|
||||
#define FIRMWARE_VER "1.0.12"
|
||||
#define FIRMWARE_VER "1.0.13"
|
||||
/* 设备硬件版本号 */
|
||||
#define HARDWARE_VER "1.0.0"
|
||||
/* 设备软件版本号 */
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#define LIGHT_FLASH_FREQUENCY_HZ 2 // Hz for entry indication flashing
|
||||
|
||||
#define SINGLE_LIGHT_TEST_DURATION_MS 3000 // 3 seconds for white/yellow light test
|
||||
#define LIGHT_CYCLE_SWITCH_DURATION_MS 1500 // 1.5 seconds for each light mode in cycle
|
||||
#define NEUTRAL_LIGHT_DUTY_RATIO (PWM_DUTY_RATIO_MAX / 2) // 50% duty ratio for neutral light
|
||||
|
||||
#define WIFI_IFNAME_MAX_SIZE 16
|
||||
#define WIFI_MAX_SSID_LEN 33
|
||||
@@ -241,6 +243,35 @@ int factory_test_init(void)
|
||||
e_printf("%s::STA enable succ.\r\n", WIFI_STA_SAMPLE_LOG);
|
||||
return 0;
|
||||
}
|
||||
// --- New Light Cycle Loop Function ---
|
||||
static void run_light_cycle_loop(void) {
|
||||
e_printf("FactoryTest: Starting light cycle loop...\n");
|
||||
|
||||
uint32_t min_duty = BRINGHTNING2PWMDUTY(BRIGHTNESS_REMOTE2LOCAL(1)); // 10% for minimum brightness
|
||||
|
||||
while (1) {
|
||||
// 1. 白光最亮 - White light max brightness
|
||||
e_printf("FactoryTest: White light max brightness\n");
|
||||
update_pwm_output(true, PWM_DUTY_RATIO_MAX, 0);
|
||||
msleep(LIGHT_CYCLE_SWITCH_DURATION_MS);
|
||||
|
||||
// 2. 暖光最亮 - Warm light max brightness
|
||||
e_printf("FactoryTest: Warm light max brightness\n");
|
||||
update_pwm_output(true, 0, PWM_DUTY_RATIO_MAX);
|
||||
msleep(LIGHT_CYCLE_SWITCH_DURATION_MS);
|
||||
|
||||
// 3. 中性光(暖白各50%)- Neutral light (50% warm and white)
|
||||
e_printf("FactoryTest: Neutral light (50%% warm and white)\n");
|
||||
update_pwm_output(true, NEUTRAL_LIGHT_DUTY_RATIO, NEUTRAL_LIGHT_DUTY_RATIO);
|
||||
msleep(LIGHT_CYCLE_SWITCH_DURATION_MS);
|
||||
|
||||
// 4. 中性光最低亮度 - Neutral light minimum brightness
|
||||
e_printf("FactoryTest: Neutral light minimum brightness\n");
|
||||
update_pwm_output(true, min_duty / 2, min_duty / 2);
|
||||
msleep(LIGHT_CYCLE_SWITCH_DURATION_MS);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Factory Test Sequence ---
|
||||
static void run_test_sequence(void) {
|
||||
e_printf("FactoryTest: Entering test sequence.\n");
|
||||
@@ -262,40 +293,28 @@ static void run_test_sequence(void) {
|
||||
update_pwm_output(false, 0, 0);
|
||||
e_printf("FactoryTest: Entry indication finished.\n");
|
||||
|
||||
// 2. White Light Test: Max bright 3s, then off.
|
||||
e_printf("FactoryTest: Step 1 - White light test...\n");
|
||||
update_pwm_output(true, PWM_DUTY_RATIO_MAX, 0);
|
||||
msleep(SINGLE_LIGHT_TEST_DURATION_MS);
|
||||
// update_pwm_output(false, 0, 0); // Ensure both are off
|
||||
e_printf("FactoryTest: White light test finished.\n");
|
||||
// msleep(500); // Small delay before next test
|
||||
|
||||
// 3. Yellow Light Test: Max bright 3s, then off.
|
||||
e_printf("FactoryTest: Step 2 - Yellow light test...\n");
|
||||
update_pwm_output(true, 0, PWM_DUTY_RATIO_MAX);
|
||||
msleep(SINGLE_LIGHT_TEST_DURATION_MS);
|
||||
// update_pwm_output(false, 0, 0); // Ensure both are off
|
||||
e_printf("FactoryTest: Yellow light test finished.\n");
|
||||
// msleep(500); // Small delay before next test
|
||||
|
||||
// 4. Wi-Fi Signal Strength Test
|
||||
e_printf("FactoryTest: Step 3 - WiFi signal strength test...\n");
|
||||
int rssi = 0;
|
||||
// 2. Wi-Fi Signal Strength Test (moved to first step after entry indication)
|
||||
e_printf("FactoryTest: Step 1 - WiFi signal strength test...\n");
|
||||
bool wifi_test_passed = false;
|
||||
if (wifi_scan_and_check(FACTORY_TEST_RSSI_THRESHOLD) == 0) {
|
||||
wifi_test_passed = true;
|
||||
e_printf("FactoryTest: WiFi test PASSED. Signal strength is acceptable.\n");
|
||||
} else {
|
||||
e_printf("FactoryTest: WiFi test FAILED. Target AP not found in this scan.\n");
|
||||
e_printf("FactoryTest: WiFi test FAILED. Signal strength below threshold or AP not found.\n");
|
||||
}
|
||||
|
||||
// 3. Check WiFi result and decide whether to continue with light cycle
|
||||
if (wifi_test_passed) {
|
||||
update_pwm_output(true, PWM_DUTY_RATIO_MAX, PWM_DUTY_RATIO_MAX);
|
||||
e_printf("FactoryTest: Final state - Both lights ON (Max Brightness).\n");
|
||||
e_printf("FactoryTest: WiFi test passed, starting light cycle loop...\n");
|
||||
run_light_cycle_loop(); // This will loop forever
|
||||
} else {
|
||||
update_pwm_output(false, 0, 0); // Ensure lights are off if test fails
|
||||
e_printf("FactoryTest: Final state - All lights OFF.\n");
|
||||
e_printf("FactoryTest: WiFi test failed, keeping neutral light on.\n");
|
||||
update_pwm_output(false, 0, 0); // Keep neutral light on
|
||||
// Stay in factory test mode but don't run light cycle
|
||||
while (1) {
|
||||
msleep(1000); // Just wait indefinitely
|
||||
}
|
||||
}
|
||||
e_printf("FactoryTest: Sequence complete.\n");
|
||||
}
|
||||
|
||||
// --- Main Factory Test Trigger Function ---
|
||||
|
||||
BIN
output/SR_light-LPT262_hilink-20250813-1.0.13.fwpkg
Normal file
BIN
output/SR_light-LPT262_hilink-20250813-1.0.13.fwpkg
Normal file
Binary file not shown.
BIN
output/package(SR_light-LPT262_hilink-20250813-1.0.13).zip
Normal file
BIN
output/package(SR_light-LPT262_hilink-20250813-1.0.13).zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user