diff --git a/main/iot/things/battery.cc b/main/iot/things/battery.cc index d503a4ed..4bded669 100644 --- a/main/iot/things/battery.cc +++ b/main/iot/things/battery.cc @@ -15,16 +15,16 @@ private: bool discharging_ = false; public: - Battery() : Thing("Battery", "电池管理") { + Battery() : Thing("Battery", "The battery of the device") { // 定义设备的属性 - properties_.AddNumberProperty("level", "当前电量百分比", [this]() -> int { + properties_.AddNumberProperty("level", "Current battery level", [this]() -> int { auto& board = Board::GetInstance(); if (board.GetBatteryLevel(level_, charging_, discharging_)) { return level_; } return 0; }); - properties_.AddBooleanProperty("charging", "是否充电中", [this]() -> int { + properties_.AddBooleanProperty("charging", "Whether the battery is charging", [this]() -> int { return charging_; }); } diff --git a/main/iot/things/lamp.cc b/main/iot/things/lamp.cc index cf016d47..e50f5425 100644 --- a/main/iot/things/lamp.cc +++ b/main/iot/things/lamp.cc @@ -32,21 +32,21 @@ private: } public: - Lamp() : Thing("Lamp", "一个测试用的灯"), power_(false) { + Lamp() : Thing("Lamp", "A test lamp"), power_(false) { InitializeGpio(); // 定义设备的属性 - properties_.AddBooleanProperty("power", "灯是否打开", [this]() -> bool { + properties_.AddBooleanProperty("power", "Whether the lamp is on", [this]() -> bool { return power_; }); // 定义设备可以被远程执行的指令 - methods_.AddMethod("TurnOn", "打开灯", ParameterList(), [this](const ParameterList& parameters) { + methods_.AddMethod("turn_on", "Turn on the lamp", ParameterList(), [this](const ParameterList& parameters) { power_ = true; gpio_set_level(gpio_num_, 1); }); - methods_.AddMethod("TurnOff", "关闭灯", ParameterList(), [this](const ParameterList& parameters) { + methods_.AddMethod("turn_off", "Turn off the lamp", ParameterList(), [this](const ParameterList& parameters) { power_ = false; gpio_set_level(gpio_num_, 0); }); diff --git a/main/iot/things/screen.cc b/main/iot/things/screen.cc index eea16064..683365dd 100644 --- a/main/iot/things/screen.cc +++ b/main/iot/things/screen.cc @@ -13,22 +13,22 @@ namespace iot { // 这里仅定义 Screen 的属性和方法,不包含具体的实现 class Screen : public Thing { public: - Screen() : Thing("Screen", "这是一个屏幕,可设置主题和亮度") { + Screen() : Thing("Screen", "A screen that can set theme and brightness") { // 定义设备的属性 - properties_.AddStringProperty("theme", "主题", [this]() -> std::string { + properties_.AddStringProperty("theme", "Current theme", [this]() -> std::string { auto theme = Board::GetInstance().GetDisplay()->GetTheme(); return theme; }); - properties_.AddNumberProperty("brightness", "当前亮度百分比", [this]() -> int { + properties_.AddNumberProperty("brightness", "Current brightness percentage", [this]() -> int { // 这里可以添加获取当前亮度的逻辑 auto backlight = Board::GetInstance().GetBacklight(); return backlight ? backlight->brightness() : 100; }); // 定义设备可以被远程执行的指令 - methods_.AddMethod("SetTheme", "设置屏幕主题", ParameterList({ - Parameter("theme_name", "主题模式, light 或 dark", kValueTypeString, true) + methods_.AddMethod("set_theme", "Set the screen theme", ParameterList({ + Parameter("theme_name", "Valid string values are \"light\" and \"dark\"", kValueTypeString, true) }), [this](const ParameterList& parameters) { std::string theme_name = static_cast(parameters["theme_name"].string()); auto display = Board::GetInstance().GetDisplay(); @@ -37,8 +37,8 @@ public: } }); - methods_.AddMethod("SetBrightness", "设置亮度", ParameterList({ - Parameter("brightness", "0到100之间的整数", kValueTypeNumber, true) + methods_.AddMethod("set_brightness", "Set the brightness", ParameterList({ + Parameter("brightness", "An integer between 0 and 100", kValueTypeNumber, true) }), [this](const ParameterList& parameters) { uint8_t brightness = static_cast(parameters["brightness"].number()); auto backlight = Board::GetInstance().GetBacklight(); diff --git a/main/iot/things/speaker.cc b/main/iot/things/speaker.cc index 689cd2a8..cf15beb1 100644 --- a/main/iot/things/speaker.cc +++ b/main/iot/things/speaker.cc @@ -11,16 +11,16 @@ namespace iot { // 这里仅定义 Speaker 的属性和方法,不包含具体的实现 class Speaker : public Thing { public: - Speaker() : Thing("Speaker", "扬声器") { + Speaker() : Thing("AudioSpeaker", "The audio speaker of the device") { // 定义设备的属性 - properties_.AddNumberProperty("volume", "当前音量值", [this]() -> int { + properties_.AddNumberProperty("volume", "Current audio volume value", [this]() -> int { auto codec = Board::GetInstance().GetAudioCodec(); return codec->output_volume(); }); // 定义设备可以被远程执行的指令 - methods_.AddMethod("SetVolume", "设置音量", ParameterList({ - Parameter("volume", "0到100之间的整数", kValueTypeNumber, true) + methods_.AddMethod("set_volume", "Set the audio volume", ParameterList({ + Parameter("volume", "An integer between 0 and 100", kValueTypeNumber, true) }), [this](const ParameterList& parameters) { auto codec = Board::GetInstance().GetAudioCodec(); codec->SetOutputVolume(static_cast(parameters["volume"].number()));