Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/cellular/framework/AT/AT_CellularContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ bool AT_CellularContext::set_new_context(int cid)
strncpy(pdp_type_str, "IPV6", sizeof(pdp_type_str));
pdp_type = IPV6_PDP_TYPE;
} else if (modem_supports_ipv4) {
strncpy(pdp_type_str, "IP", sizeof(pdp_type));
strncpy(pdp_type_str, "IP", sizeof(pdp_type_str));
pdp_type = IPV4_PDP_TYPE;
} else {
return false;
Expand Down
23 changes: 15 additions & 8 deletions features/cellular/framework/device/CellularStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
const int STM_STOPPED = -99;
const int ACTIVE_PDP_CONTEXT = 0x01;
const int ATTACHED_TO_NETWORK = 0x02;
const int DEVICE_READY = 0x04;

namespace mbed {

Expand All @@ -48,7 +49,7 @@ CellularStateMachine::CellularStateMachine(CellularDevice &device, events::Event
_event_status_cb(0), _network(0), _queue(queue), _queue_thread(0), _sim_pin(0),
_retry_count(0), _event_timeout(-1), _event_id(-1), _plmn(0), _command_success(false),
_plmn_network_found(false), _is_retry(false), _cb_data(), _current_event(NSAPI_EVENT_CONNECTION_STATUS_CHANGE),
_network_status(0)
_status(0)
{
#if MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY == 0
_start_time = 0;
Expand Down Expand Up @@ -84,7 +85,7 @@ void CellularStateMachine::reset()
_event_id = -1;
_plmn_network_found = false;
_is_retry = false;
_network_status = 0;
_status = 0;
_target_state = STATE_INIT;
enter_to_state(STATE_INIT);
}
Expand Down Expand Up @@ -112,7 +113,7 @@ bool CellularStateMachine::power_on()
{
_cb_data.error = _cellularDevice.hard_power_on();
if (_cb_data.error != NSAPI_ERROR_OK) {
tr_warn("Power on failed.");
tr_warn("Hard power on failed.");
return false;
}
return true;
Expand Down Expand Up @@ -177,7 +178,7 @@ bool CellularStateMachine::is_registered()
}

_cb_data.status_data = status;
return is_registered || _network_status;
return is_registered || _status;
}

bool CellularStateMachine::get_network_registration(CellularNetwork::RegistrationType type,
Expand Down Expand Up @@ -330,6 +331,7 @@ void CellularStateMachine::state_init()
_cellularDevice.set_timeout(TIMEOUT_POWER_ON);
tr_info("Start connecting (timeout %d s)", TIMEOUT_POWER_ON / 1000);
_cb_data.error = _cellularDevice.is_ready();
_status = _cb_data.error ? 0 : DEVICE_READY;
if (_cb_data.error != NSAPI_ERROR_OK) {
_event_timeout = _start_time;
if (_start_time > 0) {
Expand Down Expand Up @@ -381,11 +383,15 @@ bool CellularStateMachine::device_ready()
void CellularStateMachine::state_device_ready()
{
_cellularDevice.set_timeout(TIMEOUT_POWER_ON);
_cb_data.error = _cellularDevice.soft_power_on();
if (!(_status & DEVICE_READY)) {
tr_debug("Device was not ready, calling soft_power_on()");
_cb_data.error = _cellularDevice.soft_power_on();
}
if (_cb_data.error == NSAPI_ERROR_OK) {
_cb_data.error = _cellularDevice.init();
if (_cb_data.error == NSAPI_ERROR_OK) {
if (device_ready()) {
_status = 0;
enter_to_state(STATE_SIM_PIN);
}
}
Expand Down Expand Up @@ -419,11 +425,11 @@ void CellularStateMachine::state_sim_pin()

if (_network->is_active_context()) { // check if context was already activated
tr_debug("Active context found.");
_network_status |= ACTIVE_PDP_CONTEXT;
_status |= ACTIVE_PDP_CONTEXT;
}
CellularNetwork::AttachStatus status; // check if modem is already attached to a network
if (_network->get_attach(status) == NSAPI_ERROR_OK && status == CellularNetwork::Attached) {
_network_status |= ATTACHED_TO_NETWORK;
_status |= ATTACHED_TO_NETWORK;
tr_debug("Cellular already attached.");
}
if (_plmn) {
Expand Down Expand Up @@ -483,7 +489,7 @@ void CellularStateMachine::state_attaching()
{
_cellularDevice.set_timeout(TIMEOUT_CONNECT);
tr_info("Attaching network (timeout %d s)", TIMEOUT_CONNECT / 1000);
if (_network_status != ATTACHED_TO_NETWORK) {
if (_status != ATTACHED_TO_NETWORK) {
_cb_data.error = _network->set_attach();
}
if (_cb_data.error == NSAPI_ERROR_OK) {
Expand Down Expand Up @@ -724,6 +730,7 @@ void CellularStateMachine::device_ready_cb()
_event_id = -1;
if (device_ready()) {
_is_retry = false;
_status = 0;
if (!check_is_target_reached()) {
continue_from_state(STATE_SIM_PIN);
}
Expand Down
2 changes: 1 addition & 1 deletion features/cellular/framework/device/CellularStateMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class CellularStateMachine {
bool _is_retry;
cell_callback_data_t _cb_data;
nsapi_event_t _current_event;
int _network_status; // Is there any active context or is modem attached to a network?
int _status;
PlatformMutex _mutex;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "cellular/onboard_modem_api.h"
#include "UARTSerial.h"
#include "ONBOARD_TELIT_HE910.h"
#include "ThisThread.h"
#include "CellularLog.h"

using namespace mbed;

Expand All @@ -41,6 +43,8 @@ nsapi_error_t ONBOARD_TELIT_HE910::hard_power_off()
nsapi_error_t ONBOARD_TELIT_HE910::soft_power_on()
{
::onboard_modem_power_up();
// From Telit_xE910 Global form factor App note: It is mandatory to avoid sending data to the serial ports during the first 200ms of the module start-up.
rtos::ThisThread::sleep_for(200);
return NSAPI_ERROR_OK;
}

Expand All @@ -53,6 +57,12 @@ nsapi_error_t ONBOARD_TELIT_HE910::soft_power_off()
CellularDevice *CellularDevice::get_target_default_instance()
{
static UARTSerial serial(MDMTXD, MDMRXD, 115200);
#if DEVICE_SERIAL_FC
if (MDMRTS != NC && MDMCTS != NC) {
tr_debug("Modem flow control: RTS %d CTS %d", MDMRTS, MDMCTS);
serial.set_flow_control(SerialBase::RTSCTS, MDMRTS, MDMCTS);
}
#endif
static ONBOARD_TELIT_HE910 device(&serial);
return &device;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "cellular/onboard_modem_api.h"
#include "UARTSerial.h"
#include "ONBOARD_TELIT_HE910.h"
#include "ThisThread.h"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tr_debug may need CellularLog, if not coming from other includes..?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this is resolved, will start CI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Cellularlog to both targets.

#include "CellularLog.h"

using namespace mbed;
Expand All @@ -42,6 +43,8 @@ nsapi_error_t ONBOARD_TELIT_HE910::hard_power_off()
nsapi_error_t ONBOARD_TELIT_HE910::soft_power_on()
{
::onboard_modem_power_up();
// From Telit_xE910 Global form factor App note: It is mandatory to avoid sending data to the serial ports during the first 200ms of the module start-up.
rtos::ThisThread::sleep_for(200);
return NSAPI_ERROR_OK;
}

Expand Down