endpoint C207 radio support
Dependents: mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular
MBEDUbloxCellRadio.cpp@3:6acc6c8143b7, 2014-03-30 (annotated)
- Committer:
- ansond
- Date:
- Sun Mar 30 16:16:38 2014 +0000
- Revision:
- 3:6acc6c8143b7
- Parent:
- UbloxModem.cpp@1:76d2da9e2b84
- Child:
- 5:a8fd1fa0f0d0
updates
Who changed what in which revision?
User | Revision | Line number | New 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 | 1:76d2da9e2b84 | 24 | |
ansond | 1:76d2da9e2b84 | 25 | // default constructor |
ansond | 3:6acc6c8143b7 | 26 | MBEDUbloxCellRadio::MBEDUbloxCellRadio(ErrorHandler *error_handler, void *endpoint) { |
ansond | 1:76d2da9e2b84 | 27 | this->m_error_handler = error_handler; |
ansond | 1:76d2da9e2b84 | 28 | this->m_endpoint = endpoint; |
ansond | 1:76d2da9e2b84 | 29 | this->m_connected = false; |
ansond | 1:76d2da9e2b84 | 30 | this->m_c027 = new C027(); |
ansond | 1:76d2da9e2b84 | 31 | this->m_modem = NULL; |
ansond | 1:76d2da9e2b84 | 32 | } |
ansond | 1:76d2da9e2b84 | 33 | |
ansond | 1:76d2da9e2b84 | 34 | // default destructor |
ansond | 3:6acc6c8143b7 | 35 | MBEDUbloxCellRadio::~MBEDUbloxCellRadio() { |
ansond | 1:76d2da9e2b84 | 36 | if (this->m_modem != NULL) delete this->m_modem; |
ansond | 1:76d2da9e2b84 | 37 | if (this->m_c027 != NULL) delete this->m_c027; |
ansond | 1:76d2da9e2b84 | 38 | } |
ansond | 1:76d2da9e2b84 | 39 | |
ansond | 1:76d2da9e2b84 | 40 | // connect |
ansond | 3:6acc6c8143b7 | 41 | bool MBEDUbloxCellRadio::connect() { |
ansond | 1:76d2da9e2b84 | 42 | if (this->m_connected == false) { |
ansond | 1:76d2da9e2b84 | 43 | this->m_c027->mdmPower(true); |
ansond | 1:76d2da9e2b84 | 44 | this->m_c027->mdmReset(); |
ansond | 1:76d2da9e2b84 | 45 | this->m_c027->mdmWakeup(); |
ansond | 1:76d2da9e2b84 | 46 | if (this->m_modem == NULL) this->m_modem = new UBLOX_MODEM(NC, true, 1); |
ansond | 1:76d2da9e2b84 | 47 | this->m_modem->power(true); |
ansond | 1:76d2da9e2b84 | 48 | this->m_connected = true; |
ansond | 1:76d2da9e2b84 | 49 | Thread::wait(UBLOX_CDMA_CONNECT_DELAY_MS); |
ansond | 1:76d2da9e2b84 | 50 | } |
ansond | 1:76d2da9e2b84 | 51 | |
ansond | 1:76d2da9e2b84 | 52 | return this->m_connected; |
ansond | 1:76d2da9e2b84 | 53 | } |
ansond | 1:76d2da9e2b84 | 54 | |
ansond | 1:76d2da9e2b84 | 55 | // disconnect |
ansond | 3:6acc6c8143b7 | 56 | bool MBEDUbloxCellRadio::disconnect() { |
ansond | 1:76d2da9e2b84 | 57 | if (this->m_connected == true) { |
ansond | 1:76d2da9e2b84 | 58 | this->m_modem->disconnect(); |
ansond | 1:76d2da9e2b84 | 59 | this->m_c027->mdmPower(false); |
ansond | 1:76d2da9e2b84 | 60 | this->m_connected = false; |
ansond | 1:76d2da9e2b84 | 61 | } |
ansond | 1:76d2da9e2b84 | 62 | return !this->m_connected; |
ansond | 1:76d2da9e2b84 | 63 | } |
ansond | 1:76d2da9e2b84 | 64 | |
ansond | 1:76d2da9e2b84 | 65 | // ErrorHandler |
ansond | 1:76d2da9e2b84 | 66 | ErrorHandler *UbloxModem::logger() { return this->m_error_handler; } |