endpoint C207 radio support

Dependents:   mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular

Committer:
ansond
Date:
Thu Jul 03 18:35:54 2014 +0000
Revision:
20:9572d860cb54
Parent:
18:2d9bb520794c
Child:
23:a12a6b3910a9
updates for nsp based cellular

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 1:76d2da9e2b84 1 /* Copyright C2013 Doug Anson, MIT License
ansond 1:76d2da9e2b84 2 *
ansond 1:76d2da9e2b84 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ansond 1:76d2da9e2b84 4 * and associated documentation files the "Software", to deal in the Software without restriction,
ansond 1:76d2da9e2b84 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
ansond 1:76d2da9e2b84 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
ansond 1:76d2da9e2b84 7 * furnished to do so, subject to the following conditions:
ansond 1:76d2da9e2b84 8 *
ansond 1:76d2da9e2b84 9 * The above copyright notice and this permission notice shall be included in all copies or
ansond 1:76d2da9e2b84 10 * substantial portions of the Software.
ansond 1:76d2da9e2b84 11 *
ansond 1:76d2da9e2b84 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ansond 1:76d2da9e2b84 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ansond 1:76d2da9e2b84 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ansond 1:76d2da9e2b84 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ansond 1:76d2da9e2b84 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansond 1:76d2da9e2b84 17 */
ansond 1:76d2da9e2b84 18
ansond 1:76d2da9e2b84 19 // class support
ansond 3:6acc6c8143b7 20 #include "MBEDUbloxCellRadio.h"
ansond 1:76d2da9e2b84 21
ansond 1:76d2da9e2b84 22 // MBEDEndpoint support
ansond 1:76d2da9e2b84 23 #include "MBEDEndpoint.h"
ansond 9:c5db2b63ed05 24
ansond 1:76d2da9e2b84 25 // default constructor
ansond 16:19f597d8048f 26 MBEDUbloxCellRadio::MBEDUbloxCellRadio(ErrorHandler *error_handler,void *endpoint,void *modem) : BaseClass(error_handler,endpoint) {
ansond 20:9572d860cb54 27 #ifdef NSP_CELLULAR_NETWORK
ansond 20:9572d860cb54 28 this->m_modem = (MDMRtos<MDMSerial> *)modem;
ansond 20:9572d860cb54 29 #else
ansond 16:19f597d8048f 30 this->m_modem = (MDMSerial *)modem;
ansond 20:9572d860cb54 31 #endif
ansond 18:2d9bb520794c 32 #ifdef CELLULAR_DEBUG
ansond 18:2d9bb520794c 33 if (this->m_modem != NULL) this->m_modem->setDebug(4);
ansond 18:2d9bb520794c 34 #endif
ansond 1:76d2da9e2b84 35 this->m_connected = false;
ansond 1:76d2da9e2b84 36 }
ansond 1:76d2da9e2b84 37
ansond 1:76d2da9e2b84 38 // default destructor
ansond 3:6acc6c8143b7 39 MBEDUbloxCellRadio::~MBEDUbloxCellRadio() {
ansond 1:76d2da9e2b84 40 }
ansond 1:76d2da9e2b84 41
ansond 1:76d2da9e2b84 42 // connect
ansond 3:6acc6c8143b7 43 bool MBEDUbloxCellRadio::connect() {
ansond 16:19f597d8048f 44 if (this->m_connected == false)
ansond 16:19f597d8048f 45 this->m_connected = this->m_modem->connect(SIMPIN, APN,USERNAME,PASSWORD);
ansond 11:9f031bd67811 46 return this->m_connected;
ansond 1:76d2da9e2b84 47 }
ansond 1:76d2da9e2b84 48
ansond 1:76d2da9e2b84 49 // disconnect
ansond 3:6acc6c8143b7 50 bool MBEDUbloxCellRadio::disconnect() {
ansond 1:76d2da9e2b84 51 if (this->m_connected == true) {
ansond 1:76d2da9e2b84 52 this->m_modem->disconnect();
ansond 16:19f597d8048f 53 this->m_modem->powerOff();
ansond 1:76d2da9e2b84 54 this->m_connected = false;
ansond 1:76d2da9e2b84 55 }
ansond 1:76d2da9e2b84 56 return !this->m_connected;
ansond 5:a8fd1fa0f0d0 57 }