Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MTSCellularManager.cpp
- Committer:
- miaotwilio
- Date:
- 2017-05-09
- Revision:
- 0:b32fa0c757d7
- Child:
- 1:5a896191c3c4
File content as of revision 0:b32fa0c757d7:
#include "MTSCellularManager.hpp" MTSCellularManager::MTSCellularManager(const char* apn_) : apn(apn_), io(NULL), radio(NULL) { } MTSCellularManager::~MTSCellularManager() { delete radio; delete io; } bool MTSCellularManager::init() { logInfo("initializing cellular radio"); io = new mts::MTSSerialFlowControl(RADIO_TX, RADIO_RX, RADIO_RTS, RADIO_CTS); // radio default baud rate is 115200 io->baud(115200); if (! io) return false; 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); logInfo("setting APN"); if (radio->setApn(apn) != MTS_SUCCESS) { logError("failed to set APN to \"%s\"", apn); return false; } logInfo("bringing up the link"); if (! radio->connect()) { logError("failed to bring up the link"); return false; } else { return true; } } void MTSCellularManager::uninit() { logInfo("finished - bringing down link"); radio->disconnect(); delete radio; delete io; }