mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 21:18:13 +08:00
不能在功率中断里调用任何有关moloc()的操作?
This commit is contained in:
@@ -499,20 +499,13 @@ void UserMqttHassAutoPower(void)
|
||||
if (topic_buf) free(topic_buf);
|
||||
}
|
||||
|
||||
char topic_buf[64] = { 0 };
|
||||
char send_buf[32] = { 0 };
|
||||
void UserMqttHassPower(void)
|
||||
{
|
||||
char *send_buf = NULL;
|
||||
char *topic_buf = NULL;
|
||||
send_buf = malloc(512); //
|
||||
topic_buf = malloc(128); //
|
||||
if (send_buf != NULL && topic_buf != NULL)
|
||||
{
|
||||
sprintf(topic_buf, "homeassistant/sensor/%s/power/state", str_mac);
|
||||
sprintf(send_buf, "{\"power\":\"%.3f\"}", real_time_power);
|
||||
UserMqttSendTopic(topic_buf, send_buf, 0);
|
||||
}
|
||||
if (send_buf) free(send_buf);
|
||||
if (topic_buf) free(topic_buf);
|
||||
sprintf(topic_buf, "homeassistant/sensor/%s/power/state", str_mac);
|
||||
sprintf(send_buf, "{\"power\":\"%.3f\"}", real_time_power/10);
|
||||
UserMqttSendTopic(topic_buf, send_buf, 0);
|
||||
}
|
||||
|
||||
bool UserMqttIsConnect()
|
||||
|
||||
Reference in New Issue
Block a user