|
本帖最后由 uint8_t 于 2022-2-25 09:17 编辑
[md]# ESP32-C3烧入示例程序后,小爱同学无法控制
板子使用的是乐鑫官方的**ESP32-C3-DevKitM-1**,烧入的示例程序为**MIOT_OUTLET**,然后小爱同学一直提示您控制的设备出问题了。
我在程序里加了一个文字组件,用小爱同学控制时,APP里面也不会改变状态,请问这是ESP32-C3的问题吗?
用ESP8266的时候没有出现过这种情况,期待各位大佬的解答,感谢感谢!!!
通过小爱同学语音控制时,串口输出的**调试信息**为:
```
[08:54:22.066]收←◆[205977] Got: {"fromDevice":"ServerSender","data":{"get":"state","from":"MIOT","messageId":"621828be78ad36fe"}}
[205978] _messageId: 621828be78ad36fe
[205990] data: {"get":"state","from":"MIOT","messageId":"621828be78ad36fe"}
[205990] fromDevice: MIOT
[206003] form MIOT
[206022] MIOT parse data: {"get":"state","from":"MIOT","messageId":"621828be78ad36fe"}
[206023] MIOT Query codes: 0
[206023] MIOT Query All
[206035] response to MIOT: {"pState":"off"}
[206036] isJson: {"data":{"pState":"off","messageId":"621828be78ad36fe"},"fromDevice":"3F481B8FS5GBQ863V4KLA6CH","toDevice":"ServerReceiver","deviceType":"vAssistant"}
[206048] MQTT MIOT Publish...
[206060] Freeheap: 189280
[206061] BLINKER_RRPC_PUB_TOPIC_MQTT: /device/3F481B8FS5GBQ863V4KLA6CH/s
[206062] {"data":{"pState":"off","messageId":"621828be78ad36fe"},"fromDevice":"3F481B8FS5GBQ863V4KLA6CH","toDevice":"ServerReceiver","deviceType":"vAssistant"}
[206087] ...OK!
[206087] Freeheap: 187956
[08:54:22.478]收←◆[206389] Got: {"fromDevice":"ServerSender","data":{"set":{"pState":"true","pstate":"on"},"from":"MIOT","messageId":"621828bf78ad36ff"}}
[206402] _messageId: 621828bf78ad36ff
[206402] data: {"set":{"pState":"true","pstate":"on"},"from":"MIOT","messageId":"621828bf78ad36ff"}
[206415] fromDevice: MIOT
[206415] form MIOT
[206435] MIOT parse data: {"set":{"pState":"true","pstate":"on"},"from":"MIOT","messageId":"621828bf78ad36ff"}
[206435] need set power state: true
[08:54:52.493]收←◆[236417] MQTT Ping!
[236417] Freeheap: 190540
[08:55:05.783]收←◆[249695] num: 0, get Text: {"get":"state"}, length: 15
[249695] isAvail_MQTT: 1
[249714] available: 1
[249715] checkAvail: 1
[249715] parse data: {"get":"state"}
[249715] defined BLINKER_ARDUINOJSON
[249715] autoManager begin: 0 0
[249728] data_rtKeyCount: 0
[249728] autoFormatData key: state, json: "state":"online"
[249728] new.
[249740] timer codes: 000
[249740] autoFormatData key: timer, json: "timer":"000"
[249741] add.
[249741] autoFormatData key: version, json: "version":"0.1.0"
[249753] add.
[249753] print: {"state":"online","timer":"000","version":"0.1.0"}
[249766] Proto print...
[249766] Freeheap: 188552
[249766] WS response:
[249766] {"state":"online","timer":"000","version":"0.1.0"}
[249778] Success...
[249780] Freeheap: 187776
[249780] heartBeat isParsed 1
[249780] checkNum count: 1
[249780] _fresh need flush
[249792] isParsed
[249793] flush
```
完整的代码如下
```
#define BLINKER_WIFI
#define BLINKER_MIOT_OUTLET
#include <Blinker.h>
char auth[] = "176dbe060fce";
char ssid[] = "song_second";
char pswd[] = "20110722";
// 新建组件对象
BlinkerText Text1("tex-30b");//注意:要和APP组件’数据键名’一致
bool oState = false;
void miotPowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) {
//digitalWrite(LED_BUILTIN, HIGH);
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
oState = true;
}
else if (state == BLINKER_CMD_OFF) {
//digitalWrite(LED_BUILTIN, LOW);
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
oState = false;
}
Text1.print(oState ? "灯状态: 开启" : "灯状态: 关闭");
}
void miotQuery(int32_t queryCode)
{
BLINKER_LOG("MIOT Query codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_ALL_NUMBER :
BLINKER_LOG("MIOT Query All");
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
BLINKER_LOG("MIOT Query Power State");
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.print();
break;
}
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
BLINKER_DEBUG.debugAll();
//pinMode(LED_BUILTIN, OUTPUT);
//digitalWrite(LED_BUILTIN, LOW);
Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
BlinkerMIOT.attachPowerState(miotPowerState);
BlinkerMIOT.attachQuery(miotQuery);
}
void loop()
{
Blinker.run();
}
```[/md] |
|