Skip to content

Commit cb1fadc

Browse files
committed
GSM: fix device confusion
1 parent 776bb4a commit cb1fadc

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

libraries/GSM/src/GSM.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
#include "mbed.h"
44
#include "CellularLog.h"
5+
#include "CellularContext.h"
6+
#include "CellularInterface.h"
7+
#include "GEMALTO_CINTERION_CellularStack.h"
58

69
#define MAXRETRY 3
710

@@ -15,14 +18,19 @@ mbed::CellularDevice *mbed::CellularDevice::get_default_instance()
1518
}
1619

1720
int arduino::GSMClass::begin(const char* pin, const char* apn, const char* username, const char* password, RadioAccessTechnologyType rat) {
18-
if (gsm_if == nullptr) {
19-
printf("Invalid gsm_if\n");
21+
22+
_context = mbed::CellularContext::get_default_instance();
23+
24+
if (_context == nullptr) {
25+
printf("Invalid context\n");
2026
return 0;
2127
}
2228

2329
pinMode(PJ_7, INPUT_PULLDOWN);
2430
static mbed::DigitalOut rts(MBED_CONF_GEMALTO_CINTERION_RTS, 0);
2531

32+
_device = _context->get_device();
33+
2634
_context->set_sim_pin(pin);
2735

2836
_device->init();
@@ -134,7 +142,7 @@ void arduino::GSMClass::debug(Stream& stream) {
134142
}
135143

136144
NetworkInterface* arduino::GSMClass::getNetwork() {
137-
return gsm_if;
145+
return _context;
138146
}
139147

140-
arduino::GSMClass GSM(mbed::CellularContext::get_default_instance());
148+
arduino::GSMClass GSM;

libraries/GSM/src/GSM.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@ typedef void* (*voidPrtFuncPtr)(void);
4040
class GSMClass : public MbedSocketClass {
4141
public:
4242

43-
GSMClass(NetworkInterface* _if)
44-
: _rat(CATNB),
45-
gsm_if(_if),
46-
_context((mbed::CellularContext*)gsm_if),
47-
_device(((mbed::CellularContext*)gsm_if)->get_device()) {}
43+
GSMClass()
44+
: _rat(CATNB) {}
4845

4946
/* Start GSM connection.
5047
* Configure the credentials into the device.

0 commit comments

Comments
 (0)