The only thing that jumped out as something to change is line #3 of the application.cpp:
It should probably be: char request[] = "GET /php_webservice/?from=Bern&to=Bern,Inselspital HTTP/1.0"; (which works)
or
char request[] = "GET /php_webservice/index.php?from=Bern&to=Bern,Inselspital HTTP/1.0"; (which makes it really obvious whatās happening)
Or something that prompts the user to change the directory name they uploaded the index.php file into. Not a big deal for most users that would install this I guess.
So when I tried running the example on my website if I go to the URL in my browser itās returning (--)red but the response from the Spark Core is:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>ThĀ%
unknown command: HTTP/1.1 301 Moved Permanently
Date: Thu, 02 Jan 2014 17:40:18 GMT
Server: Apache
Location: http://technobly.com/php_webservice/index.php?from=Bern&to=Bern,Inselspital
Content-Length: 281
Connection: close
Content-Type: text/html; charset=iso-8859-1
BTW: I didnāt use āphp_webserviceā as my directory, so donāt think that link works above ā¦this is not whatās causing the 301 error.
I also tried changing the request to and in HTTP/1.1 and get the same error. Any ideas?
Great idea!
I need something similar - but to get the weather forecast for the next 10 hours in Germany/Ramstein to run my heating (or even not), like seen on http://de.weather.com/stĆ¼ndlich/GMXX1141:1:GM
There are a lot of savings in spring and fall, when itās cold in the morning but temperature is rising fast during the day.
Iām new to Arduino, but I did something like that already in MS Excel (Web Query + VBA), but I donāt want to run a notebook the whole year after debugging is done. Do you have some links for me to understand the basics behind ? German is ok (you are from Switzerland, right?). Many thanks in advance!
@mf2105 so you want to use the expected temperature to set your heading acordingly? Do you control the heating directly, or have some led output?
You might want to make a new topic for your idea.
LOL! Itās supposed to let you know when a good time to catch the bus is. With buses coming to stops pretty frequently, and air horn does not seem appropriate to retain any level of sanity However, coming home and finding your living room covered in whipped cream would be pretty funny.
Welp, remember when I said āthat is not whatās causing the 301 errorā ? lmaoā¦ donāt listen to me Iām obviously not a web developer. After way too much head scratching, I figured it out. I looked up a bunch of people complaining about 301 redirect errorsā¦ and it appears that sometimes itās related to mysite.com redirecting to www.mysite.com, but in my case that didnāt solve it. Most of the other reasons are due to the user actually putting in the wrong URL! Well it worked in my browser, so it must be right in my application.cpp right?? wrong! I changed the directory the index.php file was in to ābussstopā and in the application.cpp I had ābusstopāā¦ soooo, yeah. FAIL. Bright side is now I will never forget what 301 means.
But after that ego rebasing occurred, I still had an issueā¦ I wasnāt getting any kind of a response. After analyzing the request so much in the first place, I had in the back of my mind that the request was taking 1200 milliseconds to complete. Looking at the code there was a hard delay of 1000ms before attempting to process the request.
So this code change should make it more dynamicā¦ and currently I can say itās not a good time to catch a bus from Bern to Bern,Inselspital.
//wait for request to be processed.
//delay(1000);
if(DEBUG) Serial1.println("waiting for response....");
while(!client.available());
If this hangs for more than 10 - 15 seconds the core will drop off the cloud and reconnect anyway currently, so I didnāt code in a 5 - 7 second timeout in the while() loop, but it would probably be a good idea as well.
ah is see how this 303 happened, but I didnāt think about this cofigurationā¦
this delay is a good pointā¦ i think it should actually not be necessary, but the read should block until there is data. we might discuss it on the other thread:
Even if the read(); blocks it never gets there because you have && client.available() in your for() loop. First time in it sees that the client is not available and skips the loop.
@coffee Very good project!! Iām trying to modify a version for my son taking a bus every morning in Lugano.
I have troubles connecting to the server. If I try it manually I can have answer from the php script but with the firmware the program loop trying to connect. How can I check what is not working in my case?
Many thanks for every idea
This should give you a http response. if the http-response header is very long, the buffer on the spark might not be big enough. In my case, i have 5 lines of header, then two empty lines, then the answer starting with (--)
Thanks for the fast answer. As mentioned in my post the php script works fine and I receive the answer ( i.e. (ā)red, (ā)green etc. etc). I just tried the sketch on a Arduino Uno Ethernet and all is working fine!!
Only with the Spark Core I have problems connecting to the server
Thanks for the answer. After moving the php script on another web server, the problem is solved!!
I donnāt know what was the problem ā¦ but now is all working fine.
Many thanks for the help.
Now everything runs only the Core, no php script any more. And in the future I will add optional support for the Adafruit OLED 16x2 display. So you can use the LED and/or the display to show the next connections. (The display strings are ready, I just donāt have the display yet to try it).
I like this project very much. It is great :-), but if I try to compile follow error message appears, any idea?
In file included from ā¦/inc/spark_wiring.h:30:0,
from ā¦/inc/application.h:31,
from /bus-info_older_code.cpp:1:
ā¦/ā¦/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning āDefaulting to Release Buildā [-Wcpp]
/bus-info_older_code.cpp:458:0: warning: āDEBUGā redefined [enabled by default]
In file included from ā¦/inc/spark_wiring.h:32:0,
from ā¦/inc/application.h:31,
from /bus-info_older_code.cpp:1:
ā¦/ā¦/core-common-lib/SPARK_Firmware_Driver/inc/debug.h:77:0: note: this is the location of the previous definition
/bus-info_older_code.cpp:3:1: error: āStatusā does not name a type
/bus-info_older_code.cpp:4:16: error: variable or field āupdateLEDā declared void
/bus-info_older_code.cpp:4:16: error: āStatusā was not declared in this scope
/bus-info_older_code.cpp:11:1: error: āStatusā does not name a type
make: *** [/bus-info_older_code.o] Error 1
Error: Could not compile. Please review your code.