STM32F411 Example of MTSAS Cell Connection Using T-Mobile Data SIM
Dependencies: mbed
main.cpp
- Committer:
- Vanger
- Date:
- 2014-07-24
- Revision:
- 1:4c54ec0a3a20
- Parent:
- 0:47bc9ce390cc
- Child:
- 2:99606ba5d1bf
File content as of revision 1:4c54ec0a3a20:
#include "mbed.h" #include "mtsas.h" int main(){ //Modify to match your apn if you are using an HSPA radio with a SIM card const char APN[] = ""; /** STMicro Nucelo F401RE * The supported jumper configurations of the MTSAS do not line up with * the pin mapping of the Nucleo F401RE. Therefore, the MTSAS serial TX * pin (JP8 Pin 2) must be manually jumped to Serial1 RX (Shield pin D2) * and the MTSAS serial RX pin (JP9 Pin 2) pin must be manually jumped to * Serial1 TX (Shield pin D8). * Uncomment the following line to use the STMicro Nuceleo F401RE */ MTSSerialFlowControl* io = new MTSSerialFlowControl(D8, D2, D3, D6); /** Freescale KL46Z * To configure the pins for the Freescale KL46Z board, use configuration B * for the SocketModem. The TX pin should be jumped to pin D2 (JP8), and the * RX pin should be jumped to pin D9 (JP9). * Uncomment te following line to use the Freescale KL46Z board */ //MTSSerialFlowControl* io = new MTSSerialFlowControl(D2, D9, D3, D6); /** Freescale KL64F * To configure the pins for the Freescale KL46Z board, use configuration A * for the SocketModem. The TX pin should be jumped to pin D1 (JP8), and the * RX pin should be jumped to pin D0 (JP9). * Uncomment te following line to use the Freescale KL46F board */ //MTSSerialFlowControl* io = new MTSSerialFlowControl(D1, D0, D3, D6); //Sets the baudrate for communicating with the radio io->baud(115200); Cellular* radio = CellularFactory::create(io); for (int i = 0; i < 10; i++) { if (i >= 10) { printf("Failed to set APN\n"); } if (radio->setApn(APN) == MTS_SUCCESS) { printf("Successfully set APN\n"); break; } else { wait(1); } } //Establish PPP link for (int i = 0; i < 10; i++) { if (i >= 10) { printf("Failed to connect to cell network\n"); } if (radio->connect() == true) { printf("Successfully established PPP link\n"); break; } else { wait(1); } } //Ping google.com for (int i = 0; i < 10; i++) { if (i >= 10) { printf("Failed to ping google.com\n"); } if (radio->ping() == true) { printf("Successfully pinged google.com\n"); break; } else { wait(1); } } //Disconnect ppp link radio->disconnect(); printf("End of example code\n"); return 0; }