1. 解决ble 冷启动不能局域网控制的问题
之前的版本只能应对中途断网的情况。现在的应该可以应对无网启动的情况
This commit is contained in:
82
CLAUDE.md
Normal file
82
CLAUDE.md
Normal file
@ -0,0 +1,82 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Build System and Common Commands
|
||||
|
||||
### Primary Build Commands
|
||||
- `python3 build.py -c ws63-liteos-hilink` - Build HiLink firmware
|
||||
- `python3 build.py -c ws63-liteos-app-iot` - Build App-IoT firmware
|
||||
- `python3 build.py -j<num>` - Build with specified thread count (defaults to max threads)
|
||||
- `python3 build.py -clean` - Clean before building
|
||||
|
||||
### Independent Upgrade Build System
|
||||
- `python3 indie_build.py sdk` - Build HiLink SDK only with packaging
|
||||
- `python3 indie_build.py all` - Full build including HiLink + App-IoT + upgrade packages
|
||||
- `python3 package.py` - Generate upgrade package from existing binaries
|
||||
|
||||
### Pre-build Tools
|
||||
- `bash prebuild.sh` - Run pre-build tools (BLE name, product config, code generation)
|
||||
|
||||
### Build Configuration
|
||||
- Uses CMake build system with target-specific configurations
|
||||
- Configuration files located in `build/config/target_config/ws63/`
|
||||
- Supports both Unix Makefiles and Ninja generators (`-ninja` flag)
|
||||
|
||||
## Project Architecture
|
||||
|
||||
### Core Structure
|
||||
This is an embedded IoT firmware project for the WS63 chip platform with HiLink connectivity:
|
||||
|
||||
- **Target Platform**: WS63 RISC-V chip with LiteOS kernel
|
||||
- **Primary Function**: Smart lighting device with HiLink cloud connectivity
|
||||
- **Architecture**: Dual-firmware system supporting independent upgrades
|
||||
|
||||
### Key Directories
|
||||
- `application/ws63/user_main/` - Main application code including spotlight control
|
||||
- `drivers/` - Hardware abstraction layer and device drivers
|
||||
- `kernel/liteos/` - Huawei LiteOS v208.5.0 real-time operating system
|
||||
- `middleware/` - System services, utilities, and chip-specific adaptations
|
||||
- `protocol/` - Communication protocols (WiFi, Bluetooth, Radar)
|
||||
- `open_source/` - Third-party libraries (mbedTLS, GmSSL, libcoap, etc.)
|
||||
- `bootloader/` - Boot sequence and update mechanisms
|
||||
|
||||
### Firmware Components
|
||||
1. **HiLink Firmware**: Handles cloud connectivity and OTA updates
|
||||
2. **App-IoT Firmware**: Contains device-specific application logic
|
||||
3. **Independent Upgrade**: Allows updating HiLink without touching App-IoT
|
||||
|
||||
### Hardware Features
|
||||
- PWM-controlled lighting with color temperature support
|
||||
- GPIO-based controls and indicators
|
||||
- WiFi connectivity for cloud services
|
||||
- Bluetooth Low Energy support
|
||||
- Factory test and calibration modes
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Independent Upgrade Development
|
||||
When developing with independent upgrade enabled:
|
||||
1. Build HiLink firmware first: `python3 build.py -c ws63-liteos-hilink`
|
||||
2. Build App-IoT firmware: `python3 build.py -c ws63-liteos-app-iot`
|
||||
3. Generate upgrade packages: `python3 build/config/target_config/ws63/build_ws63_update.py --pkt=app_iot`
|
||||
|
||||
Or use the simplified workflow:
|
||||
- `python3 indie_build.py all` for complete build and packaging
|
||||
|
||||
### Configuration Management
|
||||
- Kconfig system for feature selection
|
||||
- Target-specific configurations in `build/config/target_config/ws63/config.py`
|
||||
- Hardware pin mappings in application code
|
||||
|
||||
### Output Artifacts
|
||||
- Complete firmware packages: `output/ws63/fwpkg/`
|
||||
- Upgrade packages: `output/ws63/upgrade/`
|
||||
- Build artifacts: `output/ws63/acore/`
|
||||
|
||||
## Key Technologies
|
||||
- **OS**: Huawei LiteOS (real-time embedded OS)
|
||||
- **Connectivity**: HiLink cloud protocol, WiFi, BLE
|
||||
- **Security**: GmSSL3.0, mbedTLS for cryptographic functions
|
||||
- **Build**: CMake with Python automation scripts
|
||||
- **Architecture**: RISC-V 32-bit processor
|
@ -72,7 +72,7 @@ typedef struct __attribute__((packed, aligned(1))) {
|
||||
uint8_t colourMode; // 色温模式 (0:单色温, 1:双色温)
|
||||
// 持久化维持
|
||||
int32_t power_on_cnt; // 上电次数计数
|
||||
uint8_t is_networked; // 是否已配网
|
||||
uint8_t is_bound; // 是否已配网
|
||||
uint8_t is_net_configured; // 设备是否曾经配网成功过
|
||||
|
||||
uint32_t reserve[10]; // 保留字段
|
||||
@ -208,7 +208,7 @@ typedef enum {
|
||||
.brightness_local = BRIGHTNESS_REMOTE2LOCAL(INIT_STA__BRIGHTNESS), \
|
||||
.fade_time = NET_CFG_DEFAULT_FADE_TIME, \
|
||||
.colourMode = COLOUR_MODE_DUAL, \
|
||||
.is_networked = false, \
|
||||
.is_bound = false, \
|
||||
.is_net_configured = false, \
|
||||
.duty_cw = 0, \
|
||||
.duty_ww = 0, \
|
||||
|
@ -689,7 +689,7 @@ void read_device_data(void)
|
||||
e_printf("主数据和备份数据都无效,使用默认值\r\n");
|
||||
// 只打印g_device_control的当前值,不打印data.control
|
||||
e_printf("上电次数: %d\r\n", g_device_control.power_on_cnt);
|
||||
e_printf("配网状态: %d\r\n", g_device_control.is_networked);
|
||||
e_printf("配网状态: %d\r\n", g_device_control.is_bound);
|
||||
e_printf("是否是新设备: %d\r\n", !g_device_control.is_net_configured);
|
||||
e_printf("开关状态: %d\r\n", g_device_control.on);
|
||||
e_printf("灯光模式: %d\r\n", g_device_control.elightMode);
|
||||
@ -703,7 +703,7 @@ void read_device_data(void)
|
||||
// 更新设备控制状态
|
||||
e_printf("设备状态恢复:\r\n");
|
||||
e_printf("上电次数: %d => %d\r\n", g_device_control.power_on_cnt, data.control.power_on_cnt);
|
||||
e_printf("配网状态: %d => %d\r\n", g_device_control.is_networked, data.control.is_networked);
|
||||
e_printf("配网状态: %d => %d\r\n", g_device_control.is_bound, data.control.is_bound);
|
||||
e_printf("是否是新设备: %d => %d\r\n", !g_device_control.is_net_configured, !data.control.is_net_configured);
|
||||
e_printf("开关状态: %d => %d\r\n", g_device_control.on, data.control.on);
|
||||
e_printf("灯光模式: %d => %d\r\n", g_device_control.elightMode, data.control.elightMode);
|
||||
@ -741,7 +741,7 @@ void save_device_data(void)
|
||||
last_control.cct_local != g_device_control.cct_local ||
|
||||
last_control.colourMode != g_device_control.colourMode ||
|
||||
last_control.power_on_cnt != g_device_control.power_on_cnt ||
|
||||
last_control.is_networked != g_device_control.is_networked ||
|
||||
last_control.is_bound != g_device_control.is_bound ||
|
||||
last_control.is_net_configured != g_device_control.is_net_configured;
|
||||
|
||||
if (!need_save) {
|
||||
@ -1041,7 +1041,9 @@ static int handle_network_status(void)
|
||||
{
|
||||
uint8_t start_net_cfg = 0;
|
||||
// 如果已经配网,直接返回
|
||||
if (g_device_control.is_networked) {
|
||||
if (g_device_control.is_bound) {
|
||||
// 如果已经配网,则设置发出ble广播确保如果没法连接路由器可以转为本地蓝牙控制
|
||||
start_hilink_ble_net_config(0xFFFFFFFF);
|
||||
return start_net_cfg;
|
||||
}
|
||||
|
||||
@ -1053,6 +1055,7 @@ static int handle_network_status(void)
|
||||
start_net_config();
|
||||
start_net_cfg = 1;
|
||||
}
|
||||
|
||||
|
||||
// 保存设备状态
|
||||
req_save_device_data();
|
||||
@ -1195,9 +1198,9 @@ void handle_device_online(void)
|
||||
}
|
||||
e_printf("device online!\r\n");
|
||||
g_device_control.is_net_configured = true;//设备上线后,认为设备已经配网成功,就取消标记为新设备,终生只存在这一次标记
|
||||
if (!g_device_control.is_networked) {
|
||||
if (!g_device_control.is_bound) {
|
||||
e_printf("设备首次上线,记录配网状态\r\n");
|
||||
g_device_control.is_networked = true;
|
||||
g_device_control.is_bound = true;
|
||||
g_device_control.power_on_cnt = 0; // 重置上电计数
|
||||
stop_breath_timer(); // 停止呼吸灯
|
||||
set_light2net_cfg_done();
|
||||
@ -1224,8 +1227,8 @@ bool g_reset_factory_flag = false;
|
||||
void handle_device_unbind(void)
|
||||
{
|
||||
e_printf("设备被解绑,重置配网状态\r\n");
|
||||
if (g_device_control.is_networked) {
|
||||
g_device_control.is_networked = false;
|
||||
if (g_device_control.is_bound) {
|
||||
g_device_control.is_bound = false;
|
||||
g_device_control.power_on_cnt = 0; // 重置上电计数
|
||||
stop_spotlight_main_task();
|
||||
device_control_t tmp = DEFAULT_DEVICE_DATA;//恢复默认
|
||||
@ -1242,7 +1245,7 @@ static void check_net_cfg_power_on_keep_time(void)
|
||||
if (g_device_control.power_on_cnt <= 0) {
|
||||
return;
|
||||
}
|
||||
if (g_device_control.is_networked) {
|
||||
if (g_device_control.is_bound) {
|
||||
return;
|
||||
}
|
||||
if (uapi_systick_get_ms() > INIT_NET_CFG_PWOER_ON_KEEP_TIME) {
|
||||
@ -1380,7 +1383,7 @@ int spotlight_main(void) {
|
||||
// set_light(DEV_POWER_ON, g_device_control.brightness_local, g_device_control.cct_local);
|
||||
}
|
||||
|
||||
if (!g_device_control.is_networked && !g_device_control.is_net_configured) {
|
||||
if (!g_device_control.is_bound && !g_device_control.is_net_configured) {
|
||||
try_detect_factory_test();
|
||||
}
|
||||
start_spotlight_main_task();
|
||||
|
@ -694,7 +694,7 @@ typedef struct __attribute__((packed, aligned(1))) {
|
||||
uint8_t colourMode; // 色温模式 (0:单色温, 1:双色温)
|
||||
// 持久化维持
|
||||
int32_t power_on_cnt; // 上电次数计数
|
||||
uint8_t is_networked; // 是否已配网
|
||||
uint8_t is_bound; // 是否已配网
|
||||
uint8_t is_net_configured; // 设备是否曾经配网成功过
|
||||
|
||||
uint32_t reserve[10]; // 保留字段
|
||||
@ -826,7 +826,7 @@ typedef enum {
|
||||
.brightness_local = BRIGHTNESS_REMOTE2LOCAL(INIT_STA__BRIGHTNESS), \
|
||||
.fade_time = NET_CFG_DEFAULT_FADE_TIME, \
|
||||
.colourMode = COLOUR_MODE_DUAL, \
|
||||
.is_networked = false, \
|
||||
.is_bound = false, \
|
||||
.is_net_configured = false, \
|
||||
.duty_cw = 0, \
|
||||
.duty_ww = 0, \
|
||||
|
@ -308,7 +308,7 @@ target = {
|
||||
"SUPPORT_MINIMALIST_NETCFG", # 极简配网
|
||||
"SUPPORT_SOFTAP_NETCFG", # softAP配网
|
||||
"SUPPORT_BLE_ANCILLAY_NETCFG", # ble辅助配网
|
||||
# "SUPPORT_QUICK_NETCFG", # 快速配网
|
||||
"SUPPORT_QUICK_NETCFG", # 快速配网
|
||||
# "CONFIG_SUPPORT_HILINK_INDIE_UPGRADE", #ekko remove for indie upgrade
|
||||
"CONFIG_SPOTLIGHT_UT", #EKKO ADD
|
||||
"CONFIG_USE_CUSTOMER_SVC_INFO", #EKKO ADD
|
||||
|
Reference in New Issue
Block a user