-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I tried SIM808_TCPConnection example. But "Hello World!" did not return. #28
Comments
It doesn't seems that mbed.org likes HTTP 1.0 (which really shouldn't come as a surprise) |
@hoerup I tried, but I get a 400 (Bad Request) error. |
Could you paste your updated code |
` #include <DFRobot_sim808.h> #define PIN_TX 10 char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.1\r\n\r\n"; void setup(){
} void loop(){ }` |
in my previous comment i did write "remember to send the host header" which is a mandatory header in http 1.1 |
Can you share sample code with me? |
char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.1\r\nHost:mbed.org\r\n\r\n"; |
I tried with the last comment and the result was: �Recv: 442 bytes: HTTP/1.1 301 Moved Permanently 301 Moved Permanentlynginx AT+CIPSTATUS So do you have a solution, please? |
The code I wrote:
`#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>
#define PIN_TX 10
#define PIN_RX 11
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,
char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\r\n\r\n";
char buffer[512];
void setup(){
mySerial.begin(9600);
Serial.begin(9600);
//******** Initialize sim808 module *************
while(!sim808.init()) {
delay(1000);
Serial.print("Sim808 init error\r\n");
}
delay(3000);
//*********** Attempt DHCP *******************
while(!sim808.join(F("cmnet"))) {
Serial.println("Sim808 join network error");
delay(2000);
}
//************ Successful DHCP ****************
Serial.print("IP Address is ");
Serial.println(sim808.getIPAddress());
//*********** Establish a TCP connection ************
if(!sim808.connect(TCP,"mbed.org", 80)) {
Serial.println("Connect error");
}else{
Serial.println("Connect mbed.org success");
}
//*********** Send a GET request *****************
Serial.println("waiting to fetch...");
sim808.send(http_cmd, sizeof(http_cmd)-1);
while (true) {
int ret = sim808.recv(buffer, sizeof(buffer)-1);
if (ret <= 0){
Serial.println("fetch over...");
break;
}
buffer[ret] = '\0';
Serial.print("Recv: ");
Serial.print(ret);
Serial.print(" bytes: ");
Serial.println(buffer);
break;
}
//************* Close TCP or UDP connections **********
sim808.close();
//*** Disconnect wireless connection, Close Moving Scene *******
sim808.disconnect();
}
void loop(){
}`
But I get such a result :
`
The text was updated successfully, but these errors were encountered: