@@ -38,8 +38,11 @@ using namespace mbed;
38
38
#define DEFAULT_AT_TIMEOUT 1000 // at default timeout in milliseconds
39
39
const int MAX_SIM_RESPONSE_LENGTH = 16 ;
40
40
41
- AT_CellularDevice::AT_CellularDevice (FileHandle *fh) : CellularDevice(fh), _network(0 ), _sms(0 ),
42
- _information(0 ), _context_list(0 ), _default_timeout(DEFAULT_AT_TIMEOUT),
41
+ AT_CellularDevice::AT_CellularDevice (FileHandle *fh) : CellularDevice(fh),
42
+ #if MBED_CONF_CELLULAR_USE_SMS
43
+ _sms (0 ),
44
+ #endif // MBED_CONF_CELLULAR_USE_SMS
45
+ _network (0 ), _information(0 ), _context_list(0 ), _default_timeout(DEFAULT_AT_TIMEOUT),
43
46
_modem_debug_on(false )
44
47
{
45
48
MBED_ASSERT (fh);
@@ -58,11 +61,17 @@ AT_CellularDevice::~AT_CellularDevice()
58
61
59
62
// make sure that all is deleted even if somewhere close was not called and reference counting is messed up.
60
63
_network_ref_count = 1 ;
64
+ #if MBED_CONF_CELLULAR_USE_SMS
61
65
_sms_ref_count = 1 ;
66
+ #endif // MBED_CONF_CELLULAR_USE_SMS
62
67
_info_ref_count = 1 ;
63
68
64
69
close_network ();
70
+
71
+ #if MBED_CONF_CELLULAR_USE_SMS
65
72
close_sms ();
73
+ #endif // MBED_CONF_CELLULAR_USE_SMS
74
+
66
75
close_information ();
67
76
68
77
AT_CellularContext *curr = _context_list;
@@ -350,15 +359,6 @@ CellularNetwork *AT_CellularDevice::open_network(FileHandle *fh)
350
359
return _network;
351
360
}
352
361
353
- CellularSMS *AT_CellularDevice::open_sms (FileHandle *fh)
354
- {
355
- if (!_sms) {
356
- _sms = open_sms_impl (*get_at_handler (fh));
357
- }
358
- _sms_ref_count++;
359
- return _sms;
360
- }
361
-
362
362
CellularInformation *AT_CellularDevice::open_information (FileHandle *fh)
363
363
{
364
364
if (!_information) {
@@ -373,10 +373,35 @@ AT_CellularNetwork *AT_CellularDevice::open_network_impl(ATHandler &at)
373
373
return new AT_CellularNetwork (at);
374
374
}
375
375
376
+ #if MBED_CONF_CELLULAR_USE_SMS
377
+
378
+ CellularSMS *AT_CellularDevice::open_sms (FileHandle *fh)
379
+ {
380
+ if (!_sms) {
381
+ _sms = open_sms_impl (*get_at_handler (fh));
382
+ }
383
+ _sms_ref_count++;
384
+ return _sms;
385
+ }
386
+
387
+ void AT_CellularDevice::close_sms ()
388
+ {
389
+ if (_sms) {
390
+ _sms_ref_count--;
391
+ if (_sms_ref_count == 0 ) {
392
+ ATHandler *atHandler = &_sms->get_at_handler ();
393
+ delete _sms;
394
+ _sms = NULL ;
395
+ release_at_handler (atHandler);
396
+ }
397
+ }
398
+ }
399
+
376
400
AT_CellularSMS *AT_CellularDevice::open_sms_impl (ATHandler &at)
377
401
{
378
402
return new AT_CellularSMS (at);
379
403
}
404
+ #endif // MBED_CONF_CELLULAR_USE_SMS
380
405
381
406
AT_CellularInformation *AT_CellularDevice::open_information_impl (ATHandler &at)
382
407
{
@@ -396,19 +421,6 @@ void AT_CellularDevice::close_network()
396
421
}
397
422
}
398
423
399
- void AT_CellularDevice::close_sms ()
400
- {
401
- if (_sms) {
402
- _sms_ref_count--;
403
- if (_sms_ref_count == 0 ) {
404
- ATHandler *atHandler = &_sms->get_at_handler ();
405
- delete _sms;
406
- _sms = NULL ;
407
- release_at_handler (atHandler);
408
- }
409
- }
410
- }
411
-
412
424
void AT_CellularDevice::close_information ()
413
425
{
414
426
if (_information) {
0 commit comments