Ignore:
Timestamp:
Apr 2, 2016, 1:19:24 PM (8 years ago)
Author:
ertl-honda
Message:

クライアントの変更に対応

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtos_arduino/trunk/examples/BlueMix_basic/rca_app.cpp

    r207 r213  
    1616char password[] = PASSWORD;
    1717
    18 ESP8266Client wifi;
    19 PubSubClient client(serverName, 1883, 0, wifi);
     18ESP8266Client wifi_client;
     19PubSubClient client(serverName, 1883, 0, wifi_client);
    2020
    21 #define SSID            ""
    22 #define WIFI_PASSWORD   ""
     21#define STA_SSID       ""
     22#define STA_PASSWORD   ""
    2323
    2424void MqttConnect()
     
    7474    Serial.println("Echo Server : Start!");
    7575   
    76     ret = wifi.begin(Serial5, 115200);
     76    ret = WiFi.begin(Serial5, 115200);
    7777
    7878    if(ret == 1) {
     
    8282        Serial.println("FW Version mismatch.");
    8383        Serial.print("FW Version:");
    84         Serial.println(wifi.getVersion().c_str());
     84        Serial.println(WiFi.getVersion().c_str());
    8585        Serial.print("Supported FW Version:");
    8686        Serial.println(ESP8266_SUPPORT_VERSION);
     
    9191
    9292    Serial.print("FW Version:");
    93     Serial.println(wifi.getVersion().c_str());
     93    Serial.println(WiFi.getVersion().c_str());
    9494   
    95     if (wifi.setOprToStation()) {
     95    if (WiFi.setOprToStation()) {
    9696        Serial.print("to station ok\r\n");
    9797    } else {
     
    9999    }
    100100   
    101     if (wifi.joinAP(SSID, WIFI_PASSWORD)) {
     101    if (WiFi.joinAP(STA_SSID, STA_PASSWORD)) {
    102102        Serial.print("Join AP success\r\n");
    103103        Serial.print("IP: ");
    104         Serial.println(wifi.getLocalIP().c_str());   
     104        Serial.println(WiFi.getLocalIP().c_str());   
    105105    } else {
    106106        Serial.print("Join AP failure\r\n");
    107107    }
    108108   
    109     if (wifi.stopServer()) {
     109    if (WiFi.stopServer()) {
    110110        Serial.print("Stop server ok\r\n");
    111111    } else {
     
    113113    }       
    114114   
    115     if (wifi.disableMUX()) {
     115    if (WiFi.disableMUX()) {
    116116        Serial.print("single ok\r\n");
    117117    } else {
     
    121121    MqttConnect();
    122122    Serial.println("MQTT set up");
    123 
    124     Wire.begin();
    125     TSL2561.init();
    126123}
    127124
    128125int cnt = 0;
    129 
    130126void loop()
    131 {
     127{   
    132128    MqttRequest(cnt++);
    133129    delay(1000);
    134130    client.loop();
     131
     132    if (Serial.available() > 0) {
     133        Serial.read();
     134        Serial.print("Pause  : Input any char to continue.\n\r");
     135        while(!(Serial.available() > 0));
     136        Serial.print("Resume.\n\r");
     137        Serial.read();
     138    }
    135139}
Note: See TracChangeset for help on using the changeset viewer.