안녕하세요 아두이노 메가보드와 블루투스 와이파이 gps 모듈을 이용하여 웹서버 구글 지도에 gps 좌표를 찍는 것을 목표로 하고 있는 학생입니다. 아래에 코드를 올렸는데 네이버 블로그를 참고하여 코드를 작성해봤습니다. 계속해서 오류코드가 뜨는데 라이브러리 문제인지 어떤 문제인지 알 수가 없네요 ㅠㅠ 도움 부탁 드립니다.
오류코드는 다음과 같습니다.
C:\Users\shin dongkyu\Desktop\NeoGPS-master\sketch_aug31a\sketch_aug31a.ino: In function 'void wifi_connect(ESP8266&, bool&)':
C:\Users\shin dongkyu\Desktop\NeoGPS-master\sketch_aug31a\sketch_aug31a.ino:79:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
BT.println(is_wifis = getStatus(wifi.joinAP(WIFI_SSID, WIFI_PASS)));
C:\Users\shin dongkyu\Desktop\NeoGPS-master\sketch_aug31a\sketch_aug31a.ino:79:67: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
sketch_aug31a:95:38: error: 'class ESP8266' has no member named 'getCIFSR'
BT.print(result = getStatus(wifi.getCIFSR(ip)));
#include <SoftwareSerial.h>
#include "ESP8266.h"
#define WIFI_SSID "iptime"
#define WIFI_PASS "123456789"
#define INTERVAL_TIME1 500L
#define INTERVAL_TIME2 2000L
#define fieldmax 13-1
HardwareSerial& BT = Serial1;
HardwareSerial& esp = Serial2;
HardwareSerial& GPS = Serial3;
ESP8266 wifi2 = ESP8266(esp);
String text = "";
bool process_sentence = false;
bool is_wifi2 = false;
double Latitude;
double Longitude;
int pos[fieldmax] = {0, };
int tempPos = 0;
unsigned int connectionId = 0;
unsigned long previous_time1 = 0;
unsigned long previous_time2 = 0;
unsigned long current_time = 0;
void setup()
{
BT.begin(9600);
GPS.begin(9600);
esp.begin(115200);
tempPos = 0;
is_wifi2 = false;
wifi_setup(wifi2);
wifi_connect(wifi2, is_wifi2);
String result;
BT.print("createServer(80): ");
BT.println(result = getStatus(wifi2.createServer( 80)));
previous_time1 = current_time = millis();
previous_time1 -= INTERVAL_TIME1;
previous_time2 = current_time = millis();
previous_time2 -= INTERVAL_TIME2;
delay(2000);
return;
}
void wifi_setup(ESP8266& wifi)
{
String result;
BT.print("restart: ");
wifi.restart();
delay(2000);
BT.print("setWifiMode: ");
BT.println(result = getStatus(wifi.setMode(ESP8266_WIFI_STATION)));
BT.print("setDHCP: ");
BT.println(result = getStatus(wifi.setDHCP(ESP8266_WIFI_STATION, true)));
BT.print("setMultipleConnections(true): ");
BT.println(result = getStatus(wifi.setMultipleConnections(true)));
return;
}
void wifi_connect(ESP8266& wifi, bool& is_wifi)
{
String is_wifis;
BT.print("joinAP: ");
BT.println(is_wifis = getStatus(wifi.joinAP(WIFI_SSID, WIFI_PASS)));
if(is_wifis.equals("OK")) is_wifi = true;
else is_wifi = false;
if (is_wifi)
{
String result;
char _ssid[100] = {};
BT.print("getAP: ");
BT.print(result = getStatus(wifi.getAP(_ssid)));
BT.print(" : ");
BT.println(_ssid);
IPAddress ip;
BT.print("getIP: ");
BT.print(result = getStatus(wifi.getCIFSR(ip)));
BT.print("IP : ");
BT.println(ip);
}
return;
}
void loop()
{
current_time = millis();
if (true)
{
while(GPS.available())
{
char c = GPS.read();
switch(c)
{
case '\n' : break;
case '\r' : process_sentence = true; break;
default: text += c; break;
}
}
if(process_sentence)
{
process_sentence = false;
if(text.startsWith("$GPRMC"))
//if(text.startsWith("$GPGGA"))
{
BT.println(text);
//print_info(BT);
print_info(BT);
}
text = "";
}
previous_time1 = current_time;
if(( (current_time - previous_time2) > INTERVAL_TIME2))
{
Web_Check();
previous_time2 = current_time;
}
}
return;
}
void Web_Check()
{
static char webbuf[1024];
if (is_wifi2)
{
long len = 0;
long int time;
bool foundIPD = false;
time = millis();
while((time + 1000) > millis())
{
while(esp.available())
{
char c = esp.read();
if(tempPos < 1024) { webbuf[tempPos] = c; tempPos++; }
}
webbuf[tempPos] = 0;
}
if(!foundIPD)
{
for (int i = 0; i < strlen(webbuf); i++)
{
if((webbuf[i]=='I') && (webbuf[i+1]=='P') && (webbuf[i+2]=='D') && (webbuf[i+3]==','))
{
foundIPD = true;
sscanf(webbuf+i+4, "%d,%ld", &connectionId, &len);
BT.println(webbuf);
BT.println("foundIPD");
tempPos = 0;
break;
}
}
}
if (foundIPD)
{
BT.println("connectionId");
BT.println(connectionId);
if(connectionId >=0)
{
Web_Page1(wifi2);
delay(2000);
}
}
}
return;
}
void Web_Page1(ESP8266& wifi)
{
String webpage;
String result;
char buf1[256];
webpage = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n";
webpage += "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"ko\">\r\n";
webpage += "<head>\r\n";
webpage += "<meta http-equiv=\"Content-Type\" content=\"application//xhtml+xml; charset=utf-8\" />\r\n";
webpage += "<meta name=\"viewport\" content=\"user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width\" />\r\n";
webpage += "<link href=\"http://code.google.com/apis/maps/documentation/javascript/examples/standard.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n";
webpage += "<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false&language=ko\"></script>\r\n";
webpage += "<script type=\"text/javascript\">\r\n";
webpage += "function initalize() {\r\n";
webpage += " var mapOptions = {\r\n";
webpage += " zoom: 15, \r\n";
sprintf(buf1, " center: now google.maps.LatLng(%s, %s),\r\n", String(Latitude,3).c_str(), String(Longitude,3).c_str());
webpage += " disableDefaultUI: true, \r\n";
webpage += " mapTypeId: google.maps.MapTypeId.ROADMAP, \r\n";
webpage += " draggable: false}\r\n";
webpage += " var map = new google.maps.Map(document.getElementById(\"map_canvas\"), mapOptions);\r\n";
webpage += " var marker = new google.maps.Marker({map:map, position: map.getCenter()});\r\n";
webpage += "}\r\n";
webpage += "</script>\r\n";
webpage += "<title> Google Map JavaScript API </title>\r\n";
webpage += "</head>\r\n";
webpage += "<body onload=\"initalize()\"> \r\n";
webpage += "<div id=\"map_canvas\" style=\"width: 640px; height: 480px; margin: 0 auto; top:50px; border: 1px solid black;\"> </div>\r\n";
webpage += "</body>\r\n";
webpage += "</html>\r\n";
BT.print(result = getStatus(wifi.send(connectionId, webpage)));
delay(500);
BT.print(result = getStatus(wifi.close(connectionId)));
return;
}
template <class T> void print_info(T& SS)
{
int start = 0;
for(int i = 0; i < fieldmax; i++)
{
pos[i] = text.indexOf(',' , start+1);
start = pos[i];
}
String vaild = Getstring(2);
String str_Latitude = Getstring(3);
String str_Longitude = Getstring(5);
if(vaild=="A")
{
Latitude = GetCoordinates(atof(str_Latitude.c_str()));
Longitude = GetCoordinates(atof(str_Longitude.c_str()));
}
SS.print("Latitude = ");
SS.println(str_Latitude);
SS.print("Longitude = ");
SS.println(str_Longitude);
return;
}
String Getstring(int index)
{
if(index >0 && index < fieldmax-1) return text.substring(pos[index-1]+1, pos[index]);
return String("");
}
double GetCoordinates(double pos)
{
int deg = (int)(pos/100);
double min = pos- deg*100.0;
return ( deg + min/60.0);
}
String getStatus(bool status)
{
if(status) return "OK";
return "NO";
}
String getStatus(ESP8266CommandStatus status)
{
switch (status) {
case ESP8266_COMMAND_INVALID:
return "INVALID";
break;
case ESP8266_COMMAND_TIMEOUT:
return "TIMEOUT";
break;
case ESP8266_COMMAND_OK:
return "OK"
break;
case ESP8266_COMMAND_NO_CHANGE:
return "NO CHANGE";
break;
case ESP8266_COMMAND_ERROR:
return "ERROR"
break;
case ESP8266_COMMAND_NO_LINK:
return "NO LINK"
break;
case ESP8266_COMMAND_TOO_LONG:
return "TOO LONG"
break;
case ESP8266_COMMAND_FAIL:
return "FAIL"
break;
default:
return "UNKNOWN COMMAND STATUS";
break;
}
}
|