endpoint C207 radio support
Dependents: mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular
Diff: MBEDUbloxCellRadio.cpp
- Revision:
- 8:ad37c7157d3c
- Parent:
- 5:a8fd1fa0f0d0
- Child:
- 9:c5db2b63ed05
--- a/MBEDUbloxCellRadio.cpp Tue Apr 01 03:23:32 2014 +0000 +++ b/MBEDUbloxCellRadio.cpp Tue Apr 01 04:46:33 2014 +0000 @@ -38,15 +38,29 @@ // connect bool MBEDUbloxCellRadio::connect() { if (this->m_connected == false) { - this->m_c027->mdmPower(true); - this->m_c027->mdmReset(); - this->m_c027->mdmWakeup(); - if (this->m_modem == NULL) this->m_modem = new UBLOX_MODEM(NC, true, 1); - this->m_modem->power(true); - this->m_connected = true; - Thread::wait(UBLOX_CDMA_DELAY_MS); + if (this->m_c027 != NULL) { + this->logger()->log("powering cell modem..."); + this->m_c027->mdmPower(true); + this->m_c027->mdmReset(); + this->logger()->log("waking up cell modem..."); + this->m_c027->mdmWakeup(); + this->logger()->log("Allocating modem instance..."); + if (this->m_modem == NULL) this->m_modem = new UBLOX_MODEM(NC, true, 1); + if (this->m_modem != NULL) { + this->logger()->log("powering modem instance..."); + this->m_modem->power(true); + this->logger()->log("waiting a bit..."); + wait_ms(UBLOX_CDMA_DELAY_MS); + this->logger()->log("connecting..."); + int ret = this->m_modem->connect("internet"); + if(ret) this->logger()->log("cellular modem connection FAILED!"); + else this->logger()->log("cellular modem connected!"); + this->m_connected = true; + } + } } + if (this->m_connected == false) this->logger()->log("cell modem connect FAILED"); return this->m_connected; }