system
September 13, 2010, 12:59pm
1
Hello there,
I have some problems with the Wifly from Sparkfun.
I want the Arduino+Wifly to autoconnect to a router and then updating my Pachube-Feeds.
The autoconnect works fine and when I'm using a terminal I'm able to update the feed manually with following lines:
open pachube.com 80
POST /api/9837.csv?_method=put HTTP/1.1
Host: www.pachube.com
X-PachubeApiKey: MYAPI
Content-type: text/csv
Content-Length: 5
Connection: close
45,70
I've tried following code for the autoupdate, but it doens't work - any ideas why?
void pachube(){
SPI_Uart_print("open pachube.com 80\r\n");
delay(2500);
SPI_Uart_println("POST /api/9837.csv?_method=put HTTP/1.1\r\n");
SPI_Uart_print("Host: www.pachube.com\r\n");
SPI_Uart_print("X-PachubeApiKey: MYAPI \r\n");
SPI_Uart_print("Content-type: text/csv\r\n");
SPI_Uart_print("Content-Length: 6\r\n");
SPI_Uart_print("Connection: close\r\n"); // note extra blank line
SPI_Uart_print("\r\n");
SPI_Uart_print("200,50\r\n");
}
Thanks for your suggestions!
system
September 13, 2010, 2:10pm
2
SPI_Uart_print[glow]ln[/glow]("POST /api/9837.csv?_method=put HTTP/1.1[glow]\r\n[/glow]");
SPI_Uart_print("Host: www.pachube.com\r\n");
You are sending a blank line, which typically says "We're all done". You aren't, are you?
system
September 13, 2010, 7:09pm
3
Well, I removed the ,,ln''. But when I remove the blank line(\r\n) it flows together like:
(...)HTTP/1.1HOST: www.pachube.com .....
Don't know what else could I do.
system
September 14, 2010, 12:04pm
4
You need to use EITHER println or the \r\n, but not both.
system
September 14, 2010, 2:03pm
5
Ah oke, I see. Well, but it doesn't help to get the things work.
I think there are some other problems.
Are there any opportunities to check if the connection to the Pachube server is opened?
My code snippet looks like this for now:
void loop()
{
//EXIT command mode
//SPI_Uart_println("exit");
Serial.println("OPEN PACHUBE");
delay(1000);
SPI_Uart_println("open pachube.com 80");
delay(5000);
SPI_Uart_print("POST /api/9837.csv?_method=put HTTP/1.1\r\n");
SPI_Uart_print("Host: www.pachube.com\r\n");
SPI_Uart_print("X-PachubeApiKey: e147d9049f3c23b1fc1109acc5e1d67ea817238ceb6c7275b41af7ce8b2d7738\r\n");
SPI_Uart_print("Content-Length: 2\r\n");
SPI_Uart_print("Connection: close\r\n");
SPI_Uart_print("\r\n");
SPI_Uart_print("56\r\n");
Serial.println("ENDE!");
delay(10000);
// Terminal routine
if(SPI_Uart_ReadByte(LSR) & 0x01) // Incoming data
{
polling = 1;
i = 0;
while(polling)
{
if((SPI_Uart_ReadByte(LSR) & 0x01))
{
incoming_data = SPI_Uart_ReadByte(RHR);
Serial.print(incoming_data,BYTE);
//Serial.print(incoming_data, HEX);
//Serial.print(" ");
}
else
{
polling = 0;
}
}
}
else if(Serial.available()) // Outgoing data
{
incoming_data = Serial.read();
select();
spi_transfer(0x00); // Transmit command
spi_transfer(incoming_data);
deselect();
}
}
system
October 12, 2010, 3:05pm
6
Hi,
You might want to try the WiFly library for Arduino I created: WiFly Shield code library alpha .
--Philip;
P.S. Also, you probably shouldn't have your API key visible.