捣蛋鬼z 2023-06-03 22:29 采纳率: 0%
浏览 178
已结题

arduino esp8266 Blinker编译报问题

arduino esp8266 编译问题
主体代码这里

#define BLINKER_MIOT_LIGHT
#define BLINKER_WIFI
 
#include <Blinker.h>
 
char auth[] ="密钥";   //换成APP获取到的密匙
char ssid[] = "wifi";  //WiFi账号
char pswd[] = "密码";   //WIFI密码
 
int GPIO=0;//定义GPIO口用于控制继电器
 
//#define BUTTON_1 "Key"
 
 
BlinkerButton Button1("Key");//这里需要根据自己在BLINKER里面设置的名字进行更改
 
void button1_callback(const String & state)
{
    //BLINKER_LOG("get button state: ", state);
    Blinker.vibrate(); 
    if (state=="on") {
        //digitalWrite(LED_BUILTIN, LOW);
        digitalWrite(GPIO, LOW);
        // 反馈开关状态
        Button1.print("on");
    } else if(state=="off"){
        //digitalWrite(LED_BUILTIN, HIGH);
        digitalWrite(GPIO, HIGH);
        // 反馈开关状态
        Button1.print("off");
    }
}
 
 
 
void miotPowerState(const String & state)
{
    BLINKER_LOG("need set power state: ",state);
 
    if (state == BLINKER_CMD_OFF) {//如果语音接收到是关闭灯就设置GPIO口为高电平
        digitalWrite(GPIO, HIGH);
 
        BlinkerMIOT.powerState("off");
        BlinkerMIOT.print();
    }
    else if (state == BLINKER_CMD_ON) {
        digitalWrite(GPIO, LOW);
        BlinkerMIOT.powerState("on");
        BlinkerMIOT.print();
    }
}
 
 
void setup() {
    Serial.begin(115200);
    //pinMode(LED_BUILTIN, OUTPUT);
    pinMode(GPIO,OUTPUT);
    digitalWrite(GPIO,HIGH);//初始化,由于继电器是低电平触发。所以刚开始设为高电平
    //digitalWrite(LED_BUILTIN, HIGH);
    Blinker.begin(auth, ssid, pswd);
    Button1.attach(button1_callback);
    BlinkerMIOT.attachPowerState(miotPowerState);//这段代码一定要加,不加小爱同学控制不了,务必在回调函数中反馈该控制状态
 
 
}
 
void loop()
{
    Blinker.run();
}

报问题信息

In file included from g:\8266xm\libraries\Blinker\src/BlinkerESPMQTT.h:16,
                 from g:\8266xm\libraries\Blinker\src/Blinker.h:43,
                 from G:\8266xm\xxdd8266\xxdd8266.ino:4:
g:\8266xm\libraries\Blinker\src/Adapters/BlinkerMQTT.h: In member function 'virtual char* BlinkerMQTT::token()':
g:\8266xm\libraries\Blinker\src/Adapters/BlinkerMQTT.h:141:50: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  141 |         char * token() { if (!isMQTTinit) return ""; else return MQTT_KEY_MQTT; }
      |                                                  ^~
In file included from g:\8266xm\libraries\Blinker\src/BlinkerESPMQTT.h:16,
                 from g:\8266xm\libraries\Blinker\src/Blinker.h:43,
                 from G:\8266xm\xxdd8266\xxdd8266.ino:4:
g:\8266xm\libraries\Blinker\src/Adapters/BlinkerMQTT.h: In member function 'virtual char* BlinkerMQTT::lastRead()':
g:\8266xm\libraries\Blinker\src/Adapters/BlinkerMQTT.h:954:17: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  954 |     else return "";
      |                 ^~
In file included from g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h:95,
                 from g:\8266xm\libraries\Blinker\src/BlinkerESPMQTT.h:17,
                 from g:\8266xm\libraries\Blinker\src/Blinker.h:43,
                 from G:\8266xm\xxdd8266\xxdd8266.ino:4:
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApiBase.h: In member function 'char* BlinkerBridge_key::getName()':
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApiBase.h:196:29: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  196 |                 else return "false";
      |                             ^~~~~~~
In file included from g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h:96,
                 from g:\8266xm\libraries\Blinker\src/BlinkerESPMQTT.h:17,
                 from g:\8266xm\libraries\Blinker\src/Blinker.h:43,
                 from G:\8266xm\xxdd8266\xxdd8266.ino:4:
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerProtocol.h: In member function 'char* BlinkerProtocol::deviceName()':
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerProtocol.h:104:86: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  104 |             char * deviceName() { if (isInit) return conn->deviceName(); else return ""; }
      |                                                                                      ^~
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerProtocol.h: In member function 'char* BlinkerProtocol::authKey()':
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerProtocol.h:105:83: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  105 |             char * authKey()    { if (isInit) return conn->authKey(); else return "";  }
      |                                                                                   ^~
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerProtocol.h: In member function 'char* BlinkerProtocol::token()':
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerProtocol.h:106:79: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  106 |             char * token()    { if (isInit) return conn->token(); else return "";  }
      |                                                                               ^~
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerProtocol.h: In member function 'char* BlinkerProtocol::dataParse()':
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerProtocol.h:257:86: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  257 |         char* dataParse()       { if (canParse) return conn->lastRead(); else return ""; }
      |                                                                                      ^~
In file included from g:\8266xm\libraries\Blinker\src/Adapters/BlinkerMQTT.h:46,
                 from g:\8266xm\libraries\Blinker\src/BlinkerESPMQTT.h:16,
                 from g:\8266xm\libraries\Blinker\src/Blinker.h:43,
                 from G:\8266xm\xxdd8266\xxdd8266.ino:4:
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h: At global scope:
g:\8266xm\libraries\blinker\src\blinker\blinkerconfig.h:226:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  226 | #define BLINKER_CMD_BUILTIN_SWITCH      "switch"
      |                                         ^~~~~~~~
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h:913:71: note: in expansion of macro 'BLINKER_CMD_BUILTIN_SWITCH'
  913 |         BlinkerWidgets_string _BUILTIN_SWITCH = BlinkerWidgets_string(BLINKER_CMD_BUILTIN_SWITCH);
      |                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from g:\8266xm\libraries\Blinker\src/BlinkerESPMQTT.h:17,
                 from g:\8266xm\libraries\Blinker\src/Blinker.h:43,
                 from G:\8266xm\xxdd8266\xxdd8266.ino:4:
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::bridgeKey(uint8_t)':
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h:7831:21: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 7831 |         else return "";
      |                     ^~
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::bridgeName(uint8_t)':
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h:7838:21: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 7838 |         else return "false";
      |                     ^~~~~~~
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_str(uint8_t)':
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h:8467:17: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 8467 |     else return "";
      |                 ^~
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_joy(uint8_t)':
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h:8474:21: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 8474 |         else return "";
      |                     ^~
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_rgb(uint8_t)':
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h:8481:17: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 8481 |     else return "";
      |                 ^~
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_int(uint8_t)':
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h:8487:17: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 8487 |     else return "";
      |                 ^~
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_tab(uint8_t)':
g:\8266xm\libraries\Blinker\src/Blinker/BlinkerApi.h:8493:17: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 8493 |     else return "";
      |                 ^~
G:\8266xm\xxdd8266\xxdd8266.ino: At global scope:
G:\8266xm\xxdd8266\xxdd8266.ino:15:23: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   15 | BlinkerButton Button1("Key");//这里需要根据自己在BLINKER里面设置的名字进行更改
      |                       ^~~~~
In file included from g:\8266xm\libraries\Blinker\src\modules\painlessMesh\scheduler.cpp:15:
g:\8266xm\libraries\blinker\src\modules\taskscheduler\taskscheduler.h: In member function 'bool Scheduler::execute()':
g:\8266xm\libraries\blinker\src\modules\taskscheduler\taskscheduler.h:872:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  872 |     register unsigned long m, i;  // millis, interval;
      |                            ^
g:\8266xm\libraries\blinker\src\modules\taskscheduler\taskscheduler.h:872:31: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  872 |     register unsigned long m, i;  // millis, interval;
      |                               ^
 
  • 写回答

6条回答 默认 最新

  • 阳光宅男xxb 2023-06-09 08:51
    关注
    获得2.25元问题酬金

    主要是一些警告信息,warning: ISO C++ forbids converting a string constant to 'char*'的意思就是禁止将字符串常量转换为“char ”,检查下你的代码中,将这种形式的定义:
    stu.name="zhangsan";
    修改为:
    char name = (char*)"zhangsan";

    其次检查下Blinker这个库,以及其他使用到的库文件是否正确引入

    评论

报告相同问题?

问题事件

  • 系统已结题 6月11日
  • 创建了问题 6月3日

悬赏问题

  • ¥15 office打开卡退(新电脑重装office系统后)
  • ¥300 FLUENT 火箭发动机燃烧EDC仿真
  • ¥15 【Hadoop 问题】Hadoop编译所遇问题hadoop-common: make failed with error code 2
  • ¥15 vb6.0+webbrowser无法加载某个网页求解
  • ¥15 RPA财务机器人采购付款流程
  • ¥15 计算机图形多边形及三次样条曲线绘制
  • ¥15 根据protues画的图用keil写程序
  • ¥200 如何使用postGis实现最短领规划?
  • ¥15 pyinstaller打包错误
  • ¥20 cesm的气溶胶排放文件