diff --git a/UNITTESTS/features/cellular/framework/AT/at_cellularbase/at_cellularbasetest.cpp b/UNITTESTS/features/cellular/framework/AT/at_cellularbase/at_cellularbasetest.cpp index 3537aa9c8a..9390ad1843 100644 --- a/UNITTESTS/features/cellular/framework/AT/at_cellularbase/at_cellularbasetest.cpp +++ b/UNITTESTS/features/cellular/framework/AT/at_cellularbase/at_cellularbasetest.cpp @@ -33,28 +33,19 @@ public: } bool check_not_supported() { - static const AT_CellularBase::SupportedFeature unsupported_features[] = { - AT_CellularBase::AT_CGSN_WITH_TYPE, - AT_CellularBase::SUPPORTED_FEATURE_END_MARK + static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = { + 0, // AT_CGSN_WITH_TYPE + 1, // AT_CGDATA + 1 // AT_CGAUTH }; - set_unsupported_features(unsupported_features); - return is_supported(AT_CGSN_WITH_TYPE); + + set_cellular_properties(cellular_properties); + return get_property(AT_CGSN_WITH_TYPE); } bool check_supported() { - set_unsupported_features(NULL); - return is_supported(AT_CGSN_WITH_TYPE); - } - - bool check_supported_not_found() - { - static const AT_CellularBase::SupportedFeature unsupported_features[] = { - AT_CellularBase::AT_CGSN_WITH_TYPE, - AT_CellularBase::SUPPORTED_FEATURE_END_MARK - }; - set_unsupported_features(unsupported_features); - return is_supported(SUPPORTED_FEATURE_END_MARK); + return get_property(AT_CGDATA); } }; @@ -109,19 +100,19 @@ TEST_F(TestAT_CellularBase, test_AT_CellularBase_get_device_error) ATHandler_stub::device_err_value.errCode = 0; } -TEST_F(TestAT_CellularBase, test_AT_CellularBase_set_unsupported_features) +TEST_F(TestAT_CellularBase, test_AT_CellularBase_set_cellular_properties) { EventQueue eq; FileHandle_stub fh; ATHandler ah(&fh, eq, 0, ","); AT_CellularBase at(ah); - static const AT_CellularBase::SupportedFeature unsupported_features[] = { - AT_CellularBase::AT_CGSN_WITH_TYPE, - AT_CellularBase::SUPPORTED_FEATURE_END_MARK + static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = { + 0, // AT_CGSN_WITH_TYPE + 1, // AT_CGDATA + 1 // AT_CGAUTH }; - - at.set_unsupported_features(unsupported_features); + at.set_cellular_properties(cellular_properties); } TEST_F(TestAT_CellularBase, test_AT_CellularBase_is_supported) @@ -131,7 +122,6 @@ TEST_F(TestAT_CellularBase, test_AT_CellularBase_is_supported) ATHandler ah(&fh, eq, 0, ","); my_base my_at(ah); - EXPECT_TRUE(true == my_at.check_supported()); - EXPECT_TRUE(true == my_at.check_supported_not_found()); - EXPECT_TRUE(false == my_at.check_not_supported()); + EXPECT_EQ(true, my_at.check_supported()); + EXPECT_EQ(false, my_at.check_not_supported()); } diff --git a/UNITTESTS/stubs/AT_CellularBase_stub.cpp b/UNITTESTS/stubs/AT_CellularBase_stub.cpp index 1c7f25a4bf..669e608229 100644 --- a/UNITTESTS/stubs/AT_CellularBase_stub.cpp +++ b/UNITTESTS/stubs/AT_CellularBase_stub.cpp @@ -16,10 +16,8 @@ */ #include "nsapi_types.h" -#include "AT_CellularBase.h" #include "AT_CellularBase_stub.h" - using namespace mbed; ATHandler *AT_CellularBase_stub::handler_value = NULL; @@ -43,7 +41,7 @@ device_err_t AT_CellularBase::get_device_error() const return AT_CellularBase_stub::device_err_value; } -bool AT_CellularBase::is_supported(SupportedFeature feature) +intptr_t AT_CellularBase::get_property(CellularProperty key) { return AT_CellularBase_stub::supported_bool; } diff --git a/UNITTESTS/stubs/AT_CellularBase_stub.h b/UNITTESTS/stubs/AT_CellularBase_stub.h index ec32d8eb28..bbf63882fe 100644 --- a/UNITTESTS/stubs/AT_CellularBase_stub.h +++ b/UNITTESTS/stubs/AT_CellularBase_stub.h @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "ATHandler.h" +#include "AT_CellularBase.h" namespace AT_CellularBase_stub { extern mbed::ATHandler *handler_value; diff --git a/features/cellular/framework/AT/AT_CellularBase.cpp b/features/cellular/framework/AT/AT_CellularBase.cpp index f1225fcfa6..8d9ab8e1f8 100644 --- a/features/cellular/framework/AT/AT_CellularBase.cpp +++ b/features/cellular/framework/AT/AT_CellularBase.cpp @@ -34,25 +34,19 @@ device_err_t AT_CellularBase::get_device_error() const return _at.get_last_device_error(); } -AT_CellularBase::SupportedFeature const *AT_CellularBase::_unsupported_features; +const intptr_t *AT_CellularBase::_property_array; -void AT_CellularBase::set_unsupported_features(const SupportedFeature *unsupported_features) +void AT_CellularBase::set_cellular_properties(const intptr_t *property_array) { - _unsupported_features = unsupported_features; -} - -bool AT_CellularBase::is_supported(SupportedFeature feature) -{ - if (!_unsupported_features) { - return true; + if (!property_array) { + tr_warning("trying to set an empty cellular property array"); + return; } - for (int i = 0; _unsupported_features[i] != SUPPORTED_FEATURE_END_MARK; i++) { - if (_unsupported_features[i] == feature) { - tr_debug("Unsupported feature (%d)", (int)feature); - return false; - } - } - - return true; + _property_array = property_array; +} + +intptr_t AT_CellularBase::get_property(CellularProperty key) +{ + return _property_array[key]; } diff --git a/features/cellular/framework/AT/AT_CellularBase.h b/features/cellular/framework/AT/AT_CellularBase.h index 218167c863..c7be9964b2 100644 --- a/features/cellular/framework/AT/AT_CellularBase.h +++ b/features/cellular/framework/AT/AT_CellularBase.h @@ -42,30 +42,31 @@ public: */ device_err_t get_device_error() const; - /** Cellular module need to define an array of unsupported features if any, - * by default all features are supported. - * - * @param features Array of type SupportedFeature with last element FEATURE_END_MARK - */ - enum SupportedFeature { - AT_CGSN_WITH_TYPE, // AT+CGSN without type is likely always supported similar to AT+GSN - AT_CGDATA, // alternative is to support only ATD*99***# - AT_CGAUTH, // APN authentication AT commands supported - SUPPORTED_FEATURE_END_MARK // must be last element in the array of features + enum CellularProperty { + AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN. + AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***# + AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported + CELLULAR_PROPERTY_MAX }; - static void set_unsupported_features(const SupportedFeature *unsupported_features); + + /** Cellular module need to define an array of cellular properties which defines module supported property values. + * + * @param property_array array of module properties + */ + static void set_cellular_properties(const intptr_t *property_array); protected: + + static const intptr_t *_property_array; + ATHandler &_at; - /** Check if some functionality is supported by a cellular module. For example, - * most of standard AT commands are optional and not implemented by all cellular modules. + /** Get value for the given key. * - * @param feature check for feature to support - * @return true on supported, otherwise false + * @param key key for value to be fetched + * @return property value for the given key. Value type is defined in enum CellularProperty */ - static const SupportedFeature *_unsupported_features; - static bool is_supported(SupportedFeature feature); + static intptr_t get_property(CellularProperty key); }; } // namespace mbed diff --git a/features/cellular/framework/AT/AT_CellularContext.cpp b/features/cellular/framework/AT/AT_CellularContext.cpp index a2a7ddd1fa..f751d6e1d9 100644 --- a/features/cellular/framework/AT/AT_CellularContext.cpp +++ b/features/cellular/framework/AT/AT_CellularContext.cpp @@ -289,7 +289,7 @@ nsapi_error_t AT_CellularContext::do_user_authentication() { // if user has defined user name and password we need to call CGAUTH before activating or modifying context if (_pwd && _uname) { - if (!is_supported(AT_CGAUTH)) { + if (!get_property(AT_CGAUTH)) { return NSAPI_ERROR_UNSUPPORTED; } _at.cmd_start("AT+CGAUTH="); @@ -572,7 +572,7 @@ void AT_CellularContext::do_connect() nsapi_error_t AT_CellularContext::open_data_channel() { tr_info("CellularContext PPP connect"); - if (is_supported(AT_CGDATA)) { + if (get_property(AT_CGDATA)) { _at.cmd_start("AT+CGDATA=\"PPP\","); _at.write_int(_cid); } else { diff --git a/features/cellular/framework/AT/AT_CellularInformation.cpp b/features/cellular/framework/AT/AT_CellularInformation.cpp index 585cd211e8..f536765fe0 100644 --- a/features/cellular/framework/AT/AT_CellularInformation.cpp +++ b/features/cellular/framework/AT/AT_CellularInformation.cpp @@ -54,7 +54,7 @@ nsapi_error_t AT_CellularInformation::get_serial_number(char *buf, size_t buf_si return get_info("AT+CGSN", buf, buf_size); } - if (!is_supported(AT_CGSN_WITH_TYPE)) { + if (!get_property(AT_CGSN_WITH_TYPE)) { return NSAPI_ERROR_UNSUPPORTED; } diff --git a/features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp b/features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp index fc4b62e015..3350c3d014 100644 --- a/features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp +++ b/features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp @@ -94,31 +94,35 @@ GEMALTO_CINTERION::Module GEMALTO_CINTERION::get_module() void GEMALTO_CINTERION::init_module_bgs2() { // BGS2-W_ATC_V00.100 - static const AT_CellularBase::SupportedFeature unsupported_features[] = { - AT_CellularBase::AT_CGSN_WITH_TYPE, - AT_CellularBase::SUPPORTED_FEATURE_END_MARK + static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = { + 0, // AT_CGSN_WITH_TYPE + 1, // AT_CGDATA + 1, // AT_CGAUTH }; - AT_CellularBase::set_unsupported_features(unsupported_features); + AT_CellularBase::set_cellular_properties(cellular_properties); _module = ModuleBGS2; } void GEMALTO_CINTERION::init_module_els61() { // ELS61-E2_ATC_V01.000 - static const AT_CellularBase::SupportedFeature unsupported_features[] = { - AT_CellularBase::AT_CGSN_WITH_TYPE, - AT_CellularBase::SUPPORTED_FEATURE_END_MARK + static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = { + 0, // AT_CGSN_WITH_TYPE + 1, // AT_CGDATA + 1, // AT_CGAUTH }; - AT_CellularBase::set_unsupported_features(unsupported_features); + AT_CellularBase::set_cellular_properties(cellular_properties); _module = ModuleELS61; } void GEMALTO_CINTERION::init_module_ems31() { // EMS31-US_ATC_V4.9.5 - static const AT_CellularBase::SupportedFeature unsupported_features[] = { - AT_CellularBase::SUPPORTED_FEATURE_END_MARK + static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = { + 1, // AT_CGSN_WITH_TYPE + 1, // AT_CGDATA + 1, // AT_CGAUTH }; - AT_CellularBase::set_unsupported_features(unsupported_features); + AT_CellularBase::set_cellular_properties(cellular_properties); _module = ModuleEMS31; } diff --git a/features/cellular/framework/targets/MultiTech/DragonflyNano/PPP/SARA4_PPP.cpp b/features/cellular/framework/targets/MultiTech/DragonflyNano/PPP/SARA4_PPP.cpp index c91941fc61..deff5ad610 100644 --- a/features/cellular/framework/targets/MultiTech/DragonflyNano/PPP/SARA4_PPP.cpp +++ b/features/cellular/framework/targets/MultiTech/DragonflyNano/PPP/SARA4_PPP.cpp @@ -23,15 +23,15 @@ using namespace mbed; using namespace events; -static const AT_CellularBase::SupportedFeature unsupported_features[] = { - AT_CellularBase::AT_CGSN_WITH_TYPE, - AT_CellularBase::AT_CGDATA, - AT_CellularBase::SUPPORTED_FEATURE_END_MARK +static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = { + 0, // AT_CGSN_WITH_TYPE + 0, // AT_CGDATA + 1 // AT_CGAUTH }; SARA4_PPP::SARA4_PPP(FileHandle *fh) : AT_CellularDevice(fh) { - AT_CellularBase::set_unsupported_features(unsupported_features); + AT_CellularBase::set_cellular_properties(cellular_properties); } SARA4_PPP::~SARA4_PPP() diff --git a/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95.cpp b/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95.cpp index 26cf6891e2..5343b23dd4 100644 --- a/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95.cpp +++ b/features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95.cpp @@ -29,14 +29,15 @@ using namespace events; using namespace mbed; -static const AT_CellularBase::SupportedFeature unsupported_features[] = { - AT_CellularBase::AT_CGAUTH, // BC95_AT_Commands_Manual_V1.9 - AT_CellularBase::SUPPORTED_FEATURE_END_MARK +static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = { + 1, // AT_CGSN_WITH_TYPE + 1, // AT_CGDATA + 0 // AT_CGAUTH, BC95_AT_Commands_Manual_V1.9 }; QUECTEL_BC95::QUECTEL_BC95(FileHandle *fh) : AT_CellularDevice(fh) { - AT_CellularBase::set_unsupported_features(unsupported_features); + AT_CellularBase::set_cellular_properties(cellular_properties); } QUECTEL_BC95::~QUECTEL_BC95() diff --git a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96.cpp b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96.cpp index 21d7e99f32..89494eb1f2 100644 --- a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96.cpp +++ b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96.cpp @@ -31,15 +31,15 @@ using namespace events; #define DEVICE_READY_URC "CPIN:" -static const AT_CellularBase::SupportedFeature unsupported_features[] = { - AT_CellularBase::AT_CGSN_WITH_TYPE, - AT_CellularBase::AT_CGDATA, - AT_CellularBase::SUPPORTED_FEATURE_END_MARK +static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = { + 0, // AT_CGSN_WITH_TYPE + 1, // AT_CGDATA + 1 // AT_CGAUTH, BC95_AT_Commands_Manual_V1.9 }; QUECTEL_BG96::QUECTEL_BG96(FileHandle *fh) : AT_CellularDevice(fh) { - AT_CellularBase::set_unsupported_features(unsupported_features); + AT_CellularBase::set_cellular_properties(cellular_properties); } QUECTEL_BG96::~QUECTEL_BG96() @@ -61,12 +61,3 @@ AT_CellularContext *QUECTEL_BG96::create_context_impl(ATHandler &at, const char return new QUECTEL_BG96_CellularContext(at, this, apn); } -AT_CellularInformation *QUECTEL_BG96::open_information_impl(ATHandler &at) -{ - return new QUECTEL_BG96_CellularInformation(at); -} - -nsapi_error_t QUECTEL_BG96::set_ready_cb(Callback callback) -{ - return _at->set_urc_handler(DEVICE_READY_URC, callback); -} diff --git a/features/cellular/framework/targets/TELIT/HE910/TELIT_HE910.cpp b/features/cellular/framework/targets/TELIT/HE910/TELIT_HE910.cpp index 21d6b51a61..75d20cb82c 100644 --- a/features/cellular/framework/targets/TELIT/HE910/TELIT_HE910.cpp +++ b/features/cellular/framework/targets/TELIT/HE910/TELIT_HE910.cpp @@ -23,15 +23,15 @@ using namespace mbed; using namespace events; -static const AT_CellularBase::SupportedFeature unsupported_features[] = { - AT_CellularBase::AT_CGSN_WITH_TYPE, // HE910/UE910/UL865/UE866 AT Commands Reference Guide Rev. 11-2006-10-14 - AT_CellularBase::AT_CGAUTH, // HE910/UE910/UL865/UE866 AT Commands Reference Guide Rev. 11-2006-10-14 - AT_CellularBase::SUPPORTED_FEATURE_END_MARK +static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = { + 0, // AT_CGSN_WITH_TYPE + 1, // AT_CGDATA + 0 // AT_CGAUTH }; TELIT_HE910::TELIT_HE910(FileHandle *fh) : AT_CellularDevice(fh) { - AT_CellularBase::set_unsupported_features(unsupported_features); + AT_CellularBase::set_cellular_properties(cellular_properties); } TELIT_HE910::~TELIT_HE910() diff --git a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp index 5532b45b93..1c2464375d 100644 --- a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp +++ b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp @@ -24,16 +24,17 @@ using namespace mbed; using namespace events; #ifdef TARGET_UBLOX_C030_R41XM -static const AT_CellularBase::SupportedFeature unsupported_features[] = { - AT_CellularBase::AT_CGSN_WITH_TYPE, - AT_CellularBase::SUPPORTED_FEATURE_END_MARK +static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = { + 0, // AT_CGSN_WITH_TYPE + 1, // AT_CGDATA + 1 // AT_CGAUTH, BC95_AT_Commands_Manual_V1.9 }; #endif UBLOX_AT::UBLOX_AT(FileHandle *fh) : AT_CellularDevice(fh) { #ifdef TARGET_UBLOX_C030_R41XM - AT_CellularBase::set_unsupported_features(unsupported_features); + AT_CellularBase::set_cellular_properties(cellular_properties); #endif } diff --git a/features/cellular/framework/targets/UBLOX/PPP/UBLOX_PPP.cpp b/features/cellular/framework/targets/UBLOX/PPP/UBLOX_PPP.cpp index d71c80d63b..b98f4ebf9f 100644 --- a/features/cellular/framework/targets/UBLOX/PPP/UBLOX_PPP.cpp +++ b/features/cellular/framework/targets/UBLOX/PPP/UBLOX_PPP.cpp @@ -24,16 +24,17 @@ using namespace mbed; using namespace events; #ifdef TARGET_UBLOX_C027 -static const AT_CellularBase::SupportedFeature unsupported_features[] = { - AT_CellularBase::AT_CGSN_WITH_TYPE, - AT_CellularBase::SUPPORTED_FEATURE_END_MARK +static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = { + 0, // AT_CGSN_WITH_TYPE + 1, // AT_CGDATA + 1 // AT_CGAUTH, BC95_AT_Commands_Manual_V1.9 }; #endif UBLOX_PPP::UBLOX_PPP(FileHandle *fh) : AT_CellularDevice(fh) { #ifdef TARGET_UBLOX_C027 - AT_CellularBase::set_unsupported_features(unsupported_features); + AT_CellularBase::set_cellular_properties(cellular_properties); #endif }