Hi there,
For GPRS: you have to configure your own APN @ const char apn[10] = “XXXX”; You can check with your SIM card carrier about the APN.
Coz I can not access <LINK_TEXT text=“https://os.mbed.com/media/uploads/mbed_ … /hello.txt”>https://os.mbed.com/media/uploads/mbed_official/hello.txt</LINK_TEXT> from my area, so i replace to raw.githubusercontent.com. If you can access mbed website. You can use this configure.
you have to connect the antenna, or else, it can not connect the network. thanks.
---------------------------------------------------------------------------
const char URL[100] = “mbed.org”;
char http_cmd[100] = “GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\r\n\r”;
---------------------------------------------------------------------------
[code]#include “MC20_Common.h”
#include “MC20_Arduino_Interface.h”
#include “MC20_GPRS.h”
#define RGBPIN 10
GPRS gprs = GPRS();
const char apn[10] = “CMNET”;
const char URL[100] = “raw.githubusercontent.com”;
char http_cmd[100] = “GET SeeedDocument/forum_doc/master/hello.txt HTTP/1.0\n\r\n\r”;
int port = 80;
int ret = 0;
void setup() {
pinMode(RGBPIN, OUTPUT);
digitalWrite(RGBPIN, LOW);
SerialUSB.begin(115200);
gprs.Power_On();
SerialUSB.println("\n\rPower On!");
if(!(ret = gprs.init(apn))) {
SerialUSB.print("GPRS init error: ");
SerialUSB.println(ret);
}
gprs.join();
SerialUSB.print("\n\rIP: ");
SerialUSB.print(gprs.ip_string);
if(gprs.connectTCP(URL, port)) {
gprs.sendTCPData(http_cmd);
} else {
SerialUSB.println(“Connect Error!”);
}
}
void loop() {
/* Debug */
if(SerialUSB.available()){
serialMC20.write(SerialUSB.read());
}
if(serialMC20.available()){
SerialUSB.write(serialMC20.read());
}
}[/code]
Here is the output from arduino serial port.
[code]
Power On!
IP:
10.11.176.242
HTTP/1.1 400 Bad Request
Server: GitHub.com
Content-Type: text/html; charset=utf-8
ETag: “5c3cbd7d-23a1”
Content-Security-Policy: default-src ‘none’; style-src ‘unsafe-inline’; img-src data:; connect-src ‘self’
X-GitHub-Request-Id: 3B94:3B5F:1E39E89:2096F1A:5CEE4C59
Accept-Ranges: bytes
Content-Length: 9121
Accept-Ranges: bytes
Date: Wed, 29 May 2019 09:09:46 GMT
Via: 1.1 varnish
Connection: close
X-Served-By: cache-lax8640-LAX
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1559120986.255221,VS0,VE27
Vary: Accept-Encoding
X-Fastly-Request-ID: 75eb3c14db3e85d903935c22fb9a7c822e9a818d
[/code]