@@ -38,8 +38,11 @@ using namespace mbed;
3838#define DEFAULT_AT_TIMEOUT 1000 // at default timeout in milliseconds
3939const int MAX_SIM_RESPONSE_LENGTH = 16 ;
4040
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),
4346 _modem_debug_on(false )
4447{
4548 MBED_ASSERT (fh);
@@ -58,11 +61,17 @@ AT_CellularDevice::~AT_CellularDevice()
5861
5962 // make sure that all is deleted even if somewhere close was not called and reference counting is messed up.
6063 _network_ref_count = 1 ;
64+ #if MBED_CONF_CELLULAR_USE_SMS
6165 _sms_ref_count = 1 ;
66+ #endif // MBED_CONF_CELLULAR_USE_SMS
6267 _info_ref_count = 1 ;
6368
6469 close_network ();
70+
71+ #if MBED_CONF_CELLULAR_USE_SMS
6572 close_sms ();
73+ #endif // MBED_CONF_CELLULAR_USE_SMS
74+
6675 close_information ();
6776
6877 AT_CellularContext *curr = _context_list;
@@ -350,15 +359,6 @@ CellularNetwork *AT_CellularDevice::open_network(FileHandle *fh)
350359 return _network;
351360}
352361
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-
362362CellularInformation *AT_CellularDevice::open_information (FileHandle *fh)
363363{
364364 if (!_information) {
@@ -373,10 +373,35 @@ AT_CellularNetwork *AT_CellularDevice::open_network_impl(ATHandler &at)
373373 return new AT_CellularNetwork (at);
374374}
375375
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+
376400AT_CellularSMS *AT_CellularDevice::open_sms_impl (ATHandler &at)
377401{
378402 return new AT_CellularSMS (at);
379403}
404+ #endif // MBED_CONF_CELLULAR_USE_SMS
380405
381406AT_CellularInformation *AT_CellularDevice::open_information_impl (ATHandler &at)
382407{
@@ -396,19 +421,6 @@ void AT_CellularDevice::close_network()
396421 }
397422}
398423
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-
412424void AT_CellularDevice::close_information ()
413425{
414426 if (_information) {
0 commit comments