手机app和语音控制反馈异常
本帖最后由 frankxu3698 于 2022-4-13 14:11 编辑求助大神!
我在做语音控制led实验中,app,天猫精灵都能控制led亮灭,但是在app和语音混合控制时会出现,语音控制后app按键没有显示反馈状态的现象。
- 产生故障的操作:app打开-按键反馈正常,同时语音控制打-串口输出正常,app关闭--按键反馈正常同时语音控制关闭或者打开-led被正确开关但是会出现app按键状态不正常现象
异常串口打印:
100413] autoFormatData key: B1, json: "B1":{"swi":"on"}
new.
print: {"B1":{"swi":"on"}}
Proto print...
Freeheap: 35168
isJson: {"data":{"B1":{"swi":"on"}},"fromDevice":"D105E068RT2LHX02GVPW73MN","toDevice":"7a8f785d0b1611eca9315254","deviceType":"OwnApp"}
MQTT Publish...
Freeheap: 35168
ERROR: MQTT NOT ALIVE OR MSG LIMIT
代码如下:
//------------------------------------------
#define BLINKER_ALIGENIE_LIGHT //天猫精灵
#define BLINKER_WIFI
#define BLINKER_APCONFIG
#include <Blinker.h>
// Download OneButton library here:
// https://github.com/mathertel/OneButton
#include "OneButton.h"
#if defined(ESP32)
#define BLINKER_BUTTON_PIN 4
#else
#define BLINKER_BUTTON_PIN 0
#endif
// button trigged when pin input level is LOW
OneButton button(BLINKER_BUTTON_PIN, true);
char auth[] = "d7a7c41cf639";
void deviceReset()
{
// Reset device ,erase WiFi config.
Blinker.reset();
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
}
//--------天猫精灵----------------------------------
// #define BLINKER_ALIGENIE_LIGHT //天猫精灵
#define Relay_Pin 16
#define LED_BUILTIN14
// 新建组件对象
BlinkerButton Button1("B1");
BlinkerNumber Number1("num-abc");
bool oState = false; //记录状态
// 按下按键即会执行该函数
void button1_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
if (state=="on") {
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(Relay_Pin,HIGH);
// 反馈开关状态
Button1.print("on");//返回app设备状态
//Button1.text("打开");
oState=1;
} else if(state=="off"){
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(Relay_Pin, LOW);
// 反馈开关状态
Button1.print("off");
//Button1.text("关闭");
oState=0;
}
}
void heartbeat()//心跳包
{
if (oState== true) {
Button1.print("on");
}
else Button1.print("off");
// Button1.icon("fas fa-lightbulb");
// Button1.color("#fddb00");
// Button1.text("关闭","打开");
//Number1.print(WiFi.RSSI());//信号强度
}
//天猫精灵
void aligeniePowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(Relay_Pin, HIGH);
BlinkerAliGenie.powerState("on");
把 Button1.print("off"); 放在 BlinkerAliGenie.print(); 之前 本帖最后由 frankxu3698 于 2022-4-14 09:22 编辑
点灯官方 发表于 2022-4-13 13:45
把 Button1.print("off"); 放在 BlinkerAliGenie.print(); 之前
感谢大神指点,不过我之前的程序就是放在前面的
页:
[1]