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
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,20 @@ class my_stack : public AT_CellularStack {
class my_AT_CTX : public AT_CellularContext {
public:
my_AT_CTX(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN) :
AT_CellularContext(at, device, apn), _st(at, *get_device())
AT_CellularContext(at, device, apn)
{
AT_CellularDevice_stub::supported_bool = false;
}
virtual ~my_AT_CTX() {}

virtual NetworkStack *get_stack()
{
return &_st;
if (!_stack) {
_stack = new my_stack(_at, *get_device());
}
return _stack;
}

virtual uint32_t get_timeout_for_operation(ContextOperation op) const
{
return 10;
Expand All @@ -137,24 +141,23 @@ class my_AT_CTX : public AT_CellularContext {
{
deactivate_non_ip_context();
}

my_stack _st;
};

class my_AT_CTXIPV6 : public AT_CellularContext {
public:
my_AT_CTXIPV6(ATHandler &at, CellularDevice *device, const char *apn = MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN) :
AT_CellularContext(at, device, apn), _st(at, *get_device()) {}
AT_CellularContext(at, device, apn) {}
virtual ~my_AT_CTXIPV6() {}
virtual NetworkStack *get_stack()
{
return &_st;
if (!_stack) {
_stack = new my_stack(_at, *get_device());
}
}
virtual uint32_t get_timeout_for_operation(ContextOperation op) const
{
return 10;
}
my_stack _st;
};

class def_AT_CTX : public AT_CellularContext {
Expand Down
11 changes: 10 additions & 1 deletion features/cellular/framework/API/CellularContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef _CELLULARCONTEXT_H_
#define _CELLULARCONTEXT_H_

#include "NetworkStack.h"
#include "CellularInterface.h"
#include "CellularDevice.h"
#include "CellularUtil.h"
Expand Down Expand Up @@ -117,7 +118,15 @@ class CellularContext : public CellularInterface {
// friend of CellularDevice, so it's the only way to close or delete this class.
friend class CellularDevice;
CellularContext();
virtual ~CellularContext() {}
virtual ~CellularContext()
{
#if !NSAPI_PPP_AVAILABLE
if (_stack) {
delete _stack;
}
#endif
}

public: // from NetworkInterface
virtual nsapi_error_t set_blocking(bool blocking) = 0;
virtual NetworkStack *get_stack() = 0;
Expand Down