捣蛋鬼z 2023-06-03 01:15 采纳率: 0%
浏览 32
已结题

arduino esp8266 编译问题

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;
      |                               ^

  • 写回答

5条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2023-06-03 04:01
    关注
    获得2.70元问题酬金
    • 文章:树莓派+arduino实现简单物联网开发(三)arduino连接esp8266控制电器 中也许有你想要的答案,请看下吧
    • 除此之外, 这篇博客: Arduino搭建Esp8266开发环境(两种方法)中的 Arduino搭建Esp8266开发环境 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
    • 简介: ESP8266是一款串口WiFi模块,内部集成MCU能实现单片机之间串口同信;这款模块简单易学,体积小,便于嵌入式开发。
      ESP8266的编程方式可以用官方的SDK编写,也可以用Arduino编写。各有各自的优点。
      在这里插入图片描述
      1. 在ArduinoIDE里面进行下载

      在这里插入图片描述

      然后我们在首选项这一个界面输入以下链接:
      http://arduino.esp8266.com/stable/package_esp8266com_index.json
      在这里插入图片描述
      然后打开开发板管理器在这里插入图片描述
      搜索8266在这里插入图片描述

      然后在工具->管理库里面:在这里插入图片描述
      需要注意的是下面的可能会报错原因可能是服务器问题。在这里插入图片描述
      然后我们输入8266就可以找到该库了
      在这里插入图片描述
      点安装后我们就可以看到开发板了,选中后即可对8266编程;
      在这里插入图片描述
      在这里插入图片描述
      最后我们编译后烧录进去,显示成功!

      2.通过工具对8266进行安装,推荐用这种方法!
      在这里插入图片描述
      在这里插入图片描述
      然后就安装完成了,
      点安装后我们就可以看到开发板了,选中后即可对8266编程;
      在这里插入图片描述
      在这里插入图片描述
      最后我们编译后烧录进去,显示成功!
      需要该软件可以关注公众号:智慧小巷
      回复:Arduino一键安装8266
      即可!
      在这里插入图片描述
      感谢阅读!

    评论

报告相同问题?

问题事件

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

悬赏问题

  • ¥18 深度学习tensorflow1,ssdv1,coco数据集训练一个模型
  • ¥100 关于注册表摄像头和麦克风的问题
  • ¥30 代码本地运行正常,但是TOMCAT部署时闪退
  • ¥15 关于#python#的问题
  • ¥15 主机可以ping通路由器但是连不上网怎么办
  • ¥15 数据库一张以时间排好序的表中,找出多次相邻的那些行
  • ¥50 关于DynamoRIO处理多线程程序时候的问题
  • ¥15 kubeadm部署k8s出错
  • ¥15 Abaqus打不开cae文件怎么办?
  • ¥15 小程序准备上线,软件开发公司需要提供哪些资料给甲方