Skip to content

Commit 55a1032

Browse files
committed
do not allocate memory if old IoT protocol is not used
1 parent 5da6677 commit 55a1032

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

main/iot/thing.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,30 @@
88

99
namespace iot {
1010

11+
#if CONFIG_IOT_PROTOCOL_XIAOZHI
1112
static std::map<std::string, std::function<Thing*()>>* thing_creators = nullptr;
13+
#endif
1214

1315
void RegisterThing(const std::string& type, std::function<Thing*()> creator) {
16+
#if CONFIG_IOT_PROTOCOL_XIAOZHI
1417
if (thing_creators == nullptr) {
1518
thing_creators = new std::map<std::string, std::function<Thing*()>>();
1619
}
1720
(*thing_creators)[type] = creator;
21+
#endif
1822
}
1923

2024
Thing* CreateThing(const std::string& type) {
25+
#if CONFIG_IOT_PROTOCOL_XIAOZHI
2126
auto creator = thing_creators->find(type);
2227
if (creator == thing_creators->end()) {
2328
ESP_LOGE(TAG, "Thing type not found: %s", type.c_str());
2429
return nullptr;
2530
}
2631
return creator->second();
32+
#else
33+
return nullptr;
34+
#endif
2735
}
2836

2937
std::string Thing::GetDescriptorJson() {

main/mcp_server.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void McpServer::AddCommonTools() {
3030
return Board::GetInstance().GetDeviceStatusJson();
3131
});
3232

33-
AddTool("self.speaker.set_volume",
33+
AddTool("self.audio_speaker.set_volume",
3434
"Set the volume of the audio speaker. If the current volume is unknown, you must call `self.get_device_status` tool first and then call this tool.",
3535
PropertyList({
3636
Property("volume", kPropertyTypeInteger, 0, 100)

0 commit comments

Comments
 (0)