mirror of https://github.com/ARMmbed/mbed-os.git
review changes: take define MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP in to use.
parent
1fd9ba6caa
commit
a95d376820
|
@ -28,9 +28,9 @@
|
||||||
#include "EasyCellularConnection.h"
|
#include "EasyCellularConnection.h"
|
||||||
#include "CellularLog.h"
|
#include "CellularLog.h"
|
||||||
|
|
||||||
#if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP
|
#if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
|
||||||
#include "APN_db.h"
|
#include "APN_db.h"
|
||||||
#endif //MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP
|
#endif //MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
|
||||||
|
|
||||||
namespace mbed {
|
namespace mbed {
|
||||||
|
|
||||||
|
@ -53,10 +53,13 @@ bool EasyCellularConnection::cellular_status(int state, int next_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
EasyCellularConnection::EasyCellularConnection() : _is_connected(false), _is_initialized(false),
|
EasyCellularConnection::EasyCellularConnection() : _is_connected(false), _is_initialized(false),
|
||||||
_credentials_set(false), _target_state(CellularConnectionUtil::STATE_POWER_ON),
|
_target_state(CellularConnectionUtil::STATE_POWER_ON),
|
||||||
_cellularSerial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE),
|
_cellularSerial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE),
|
||||||
_cellularSemaphore(0), _cellularConnectionUtil(), _credentials_err(NSAPI_ERROR_OK)
|
_cellularSemaphore(0), _cellularConnectionUtil(), _credentials_err(NSAPI_ERROR_OK)
|
||||||
{
|
{
|
||||||
|
#if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
|
||||||
|
_credentials_set = false;
|
||||||
|
#endif // #if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
|
||||||
tr_info("EasyCellularConnection()");
|
tr_info("EasyCellularConnection()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,9 +100,11 @@ void EasyCellularConnection::set_credentials(const char *apn, const char *uname,
|
||||||
CellularNetwork * network = _cellularConnectionUtil.get_network();
|
CellularNetwork * network = _cellularConnectionUtil.get_network();
|
||||||
if (network) {
|
if (network) {
|
||||||
_credentials_err = network->set_credentials(apn, uname, pwd);
|
_credentials_err = network->set_credentials(apn, uname, pwd);
|
||||||
|
#if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
|
||||||
if (_credentials_err == NSAPI_ERROR_OK) {
|
if (_credentials_err == NSAPI_ERROR_OK) {
|
||||||
_credentials_set = true;
|
_credentials_set = true;
|
||||||
}
|
}
|
||||||
|
#endif // #if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
|
||||||
} else {
|
} else {
|
||||||
tr_error("NO Network...");
|
tr_error("NO Network...");
|
||||||
}
|
}
|
||||||
|
@ -156,7 +161,7 @@ nsapi_error_t EasyCellularConnection::connect()
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
#if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP
|
#if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
|
||||||
if (!_credentials_set) {
|
if (!_credentials_set) {
|
||||||
_target_state = CellularConnectionUtil::STATE_SIM_PIN;
|
_target_state = CellularConnectionUtil::STATE_SIM_PIN;
|
||||||
err = _cellularConnectionUtil.continue_to_state(_target_state);
|
err = _cellularConnectionUtil.continue_to_state(_target_state);
|
||||||
|
@ -184,7 +189,7 @@ nsapi_error_t EasyCellularConnection::connect()
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP
|
#endif // MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
|
||||||
|
|
||||||
_target_state = CellularConnectionUtil::STATE_CONNECTED;
|
_target_state = CellularConnectionUtil::STATE_CONNECTED;
|
||||||
err = _cellularConnectionUtil.continue_to_state(_target_state);
|
err = _cellularConnectionUtil.continue_to_state(_target_state);
|
||||||
|
@ -203,7 +208,9 @@ nsapi_error_t EasyCellularConnection::disconnect()
|
||||||
{
|
{
|
||||||
_credentials_err = NSAPI_ERROR_OK;
|
_credentials_err = NSAPI_ERROR_OK;
|
||||||
_is_connected = false;
|
_is_connected = false;
|
||||||
|
#if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
|
||||||
_credentials_set = false;
|
_credentials_set = false;
|
||||||
|
#endif // #if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
|
||||||
if (!_cellularConnectionUtil.get_network()) {
|
if (!_cellularConnectionUtil.get_network()) {
|
||||||
return NSAPI_ERROR_NO_CONNECTION;
|
return NSAPI_ERROR_NO_CONNECTION;
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,9 @@ private:
|
||||||
|
|
||||||
bool _is_connected;
|
bool _is_connected;
|
||||||
bool _is_initialized;
|
bool _is_initialized;
|
||||||
|
#if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
|
||||||
bool _credentials_set;
|
bool _credentials_set;
|
||||||
|
#endif // #if MBED_CONF_APP_CELLULAR_USE_APN_LOOKUP || MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
|
||||||
CellularConnectionUtil::CellularState _target_state;
|
CellularConnectionUtil::CellularState _target_state;
|
||||||
|
|
||||||
UARTSerial _cellularSerial;
|
UARTSerial _cellularSerial;
|
||||||
|
|
Loading…
Reference in New Issue