Example program demonstrating proper powering down of Telit radio and putting the processor into STOP mode.
Dependencies: WakeUp mbed mtsas SpiFlash25
Fork of Dragonfly_Cellular_Ping_Example by
main.cpp
- Committer:
- mfiore
- Date:
- 2016-02-26
- Revision:
- 2:0288328818cb
- Parent:
- 1:1411b4274907
- Child:
- 3:90cf39b6ed0d
File content as of revision 2:0288328818cb:
/** Dragonfly Cellular Ping Example * Configures the cellular radio, brings up the cellular link, and pings Google. * * NOTE: This example changes the baud rate of the debug port to 115200 baud! */ #include "mbed.h" #include "mtsas.h" // This line controls the regulator's battery charger. // BC_NCE = 0 enables the battery charger // BC_NCE = 1 disables the battery charger DigitalOut bc_nce(PB_2); bool init_mtsas(); // The MTSSerialFlowControl object represents the physical serial link between the processor and the cellular radio. mts::MTSSerialFlowControl* io; // The Cellular object represents the cellular radio. mts::Cellular* radio; // An APN is required for GSM radios. static const char apn[] = ""; bool radio_ok = false; int main() { // Disable the battery charger unless a battery is attached. bc_nce = 1; // Change the baud rate of the debug port from the default 9600 to 115200. Serial debug(USBTX, USBRX); debug.baud(115200); //Sets the log level to INFO, higher log levels produce more log output. //Possible levels: NONE, FATAL, ERROR, WARNING, INFO, DEBUG, TRACE mts::MTSLog::setLogLevel(mts::MTSLog::INFO_LEVEL); logInfo("initializing cellular radio"); radio_ok = init_mtsas(); if (! radio_ok) { while (true) { logError("failed to initialize cellular radio"); wait(1); } } logInfo("setting APN"); if (radio->setApn(apn) != MTS_SUCCESS) logError("failed to set APN to \"%s\"", apn); logInfo("bringing up the link"); if (! radio->connect()) { logError("failed to bring up the link"); } else { for (int i = 0; i < 10; i++) { logInfo("pinging"); if (! radio->ping("www.google.com")) logError("failed to ping"); else logInfo("ping succeeded"); } } logInfo("finished - bringing down link"); radio->disconnect(); return 0; } bool init_mtsas() { io = new mts::MTSSerialFlowControl(RADIO_TX, RADIO_RX, RADIO_RTS, RADIO_CTS); if (! io) return false; // radio default baud rate is 115200 io->baud(115200); radio = mts::CellularFactory::create(io); if (! radio) return false; // Transport must be set properly before any TCPSocketConnection or UDPSocket objects are created Transport::setTransport(radio); return true; }