Skip to content

Commit c4138f4

Browse files
author
Cruz Monrreal
authored
Merge pull request #9050 from jarvte/support_feature_to_key_value
Cellular: changed support features to CellularProperty array.
2 parents a57bacf + 0f1e08f commit c4138f4

File tree

14 files changed

+91
-107
lines changed

14 files changed

+91
-107
lines changed

UNITTESTS/features/cellular/framework/AT/at_cellularbase/at_cellularbasetest.cpp

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,19 @@ class my_base : public AT_CellularBase {
3333
}
3434
bool check_not_supported()
3535
{
36-
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
37-
AT_CellularBase::AT_CGSN_WITH_TYPE,
38-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
36+
static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = {
37+
0, // AT_CGSN_WITH_TYPE
38+
1, // AT_CGDATA
39+
1 // AT_CGAUTH
3940
};
40-
set_unsupported_features(unsupported_features);
41-
return is_supported(AT_CGSN_WITH_TYPE);
42-
}
4341

44-
bool check_supported()
45-
{
46-
set_unsupported_features(NULL);
47-
return is_supported(AT_CGSN_WITH_TYPE);
42+
set_cellular_properties(cellular_properties);
43+
return get_property(AT_CGSN_WITH_TYPE);
4844
}
4945

50-
bool check_supported_not_found()
46+
bool check_supported()
5147
{
52-
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
53-
AT_CellularBase::AT_CGSN_WITH_TYPE,
54-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
55-
};
56-
set_unsupported_features(unsupported_features);
57-
return is_supported(SUPPORTED_FEATURE_END_MARK);
48+
return get_property(AT_CGDATA);
5849
}
5950
};
6051

@@ -109,19 +100,19 @@ TEST_F(TestAT_CellularBase, test_AT_CellularBase_get_device_error)
109100
ATHandler_stub::device_err_value.errCode = 0;
110101
}
111102

112-
TEST_F(TestAT_CellularBase, test_AT_CellularBase_set_unsupported_features)
103+
TEST_F(TestAT_CellularBase, test_AT_CellularBase_set_cellular_properties)
113104
{
114105
EventQueue eq;
115106
FileHandle_stub fh;
116107
ATHandler ah(&fh, eq, 0, ",");
117108
AT_CellularBase at(ah);
118109

119-
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
120-
AT_CellularBase::AT_CGSN_WITH_TYPE,
121-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
110+
static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = {
111+
0, // AT_CGSN_WITH_TYPE
112+
1, // AT_CGDATA
113+
1 // AT_CGAUTH
122114
};
123-
124-
at.set_unsupported_features(unsupported_features);
115+
at.set_cellular_properties(cellular_properties);
125116
}
126117

127118
TEST_F(TestAT_CellularBase, test_AT_CellularBase_is_supported)
@@ -131,7 +122,6 @@ TEST_F(TestAT_CellularBase, test_AT_CellularBase_is_supported)
131122
ATHandler ah(&fh, eq, 0, ",");
132123
my_base my_at(ah);
133124

134-
EXPECT_TRUE(true == my_at.check_supported());
135-
EXPECT_TRUE(true == my_at.check_supported_not_found());
136-
EXPECT_TRUE(false == my_at.check_not_supported());
125+
EXPECT_EQ(true, my_at.check_supported());
126+
EXPECT_EQ(false, my_at.check_not_supported());
137127
}

UNITTESTS/stubs/AT_CellularBase_stub.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
*/
1717

1818
#include "nsapi_types.h"
19-
#include "AT_CellularBase.h"
2019
#include "AT_CellularBase_stub.h"
2120

22-
2321
using namespace mbed;
2422

2523
ATHandler *AT_CellularBase_stub::handler_value = NULL;
@@ -42,7 +40,7 @@ device_err_t AT_CellularBase::get_device_error() const
4240
return AT_CellularBase_stub::device_err_value;
4341
}
4442

45-
bool AT_CellularBase::is_supported(SupportedFeature feature)
43+
intptr_t AT_CellularBase::get_property(CellularProperty key)
4644
{
4745
return AT_CellularBase_stub::supported_bool;
4846
}

UNITTESTS/stubs/AT_CellularBase_stub.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include "ATHandler.h"
18+
#include "AT_CellularBase.h"
1919

2020
namespace AT_CellularBase_stub {
2121
extern mbed::ATHandler *handler_value;

features/cellular/framework/AT/AT_CellularBase.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,19 @@ device_err_t AT_CellularBase::get_device_error() const
3434
return _at.get_last_device_error();
3535
}
3636

37-
AT_CellularBase::SupportedFeature const *AT_CellularBase::_unsupported_features;
37+
const intptr_t *AT_CellularBase::_property_array;
3838

39-
void AT_CellularBase::set_unsupported_features(const SupportedFeature *unsupported_features)
39+
void AT_CellularBase::set_cellular_properties(const intptr_t *property_array)
4040
{
41-
_unsupported_features = unsupported_features;
42-
}
43-
44-
bool AT_CellularBase::is_supported(SupportedFeature feature)
45-
{
46-
if (!_unsupported_features) {
47-
return true;
41+
if (!property_array) {
42+
tr_warning("trying to set an empty cellular property array");
43+
return;
4844
}
4945

50-
for (int i = 0; _unsupported_features[i] != SUPPORTED_FEATURE_END_MARK; i++) {
51-
if (_unsupported_features[i] == feature) {
52-
tr_debug("Unsupported feature (%d)", (int)feature);
53-
return false;
54-
}
55-
}
46+
_property_array = property_array;
47+
}
5648

57-
return true;
49+
intptr_t AT_CellularBase::get_property(CellularProperty key)
50+
{
51+
return _property_array[key];
5852
}

features/cellular/framework/AT/AT_CellularBase.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,31 @@ class AT_CellularBase {
4242
*/
4343
device_err_t get_device_error() const;
4444

45-
/** Cellular module need to define an array of unsupported features if any,
46-
* by default all features are supported.
45+
enum CellularProperty {
46+
AT_CGSN_WITH_TYPE, // 0 = not supported, 1 = supported. AT+CGSN without type is likely always supported similar to AT+GSN.
47+
AT_CGDATA, // 0 = not supported, 1 = supported. Alternative is to support only ATD*99***<cid>#
48+
AT_CGAUTH, // 0 = not supported, 1 = supported. APN authentication AT commands supported
49+
CELLULAR_PROPERTY_MAX
50+
};
51+
52+
/** Cellular module need to define an array of cellular properties which defines module supported property values.
4753
*
48-
* @param features Array of type SupportedFeature with last element FEATURE_END_MARK
54+
* @param property_array array of module properties
4955
*/
50-
enum SupportedFeature {
51-
AT_CGSN_WITH_TYPE, // AT+CGSN without type is likely always supported similar to AT+GSN
52-
AT_CGDATA, // alternative is to support only ATD*99***<cid>#
53-
AT_CGAUTH, // APN authentication AT commands supported
54-
SUPPORTED_FEATURE_END_MARK // must be last element in the array of features
55-
};
56-
static void set_unsupported_features(const SupportedFeature *unsupported_features);
56+
static void set_cellular_properties(const intptr_t *property_array);
5757

5858
protected:
59+
60+
static const intptr_t *_property_array;
61+
5962
ATHandler &_at;
6063

61-
/** Check if some functionality is supported by a cellular module. For example,
62-
* most of standard AT commands are optional and not implemented by all cellular modules.
64+
/** Get value for the given key.
6365
*
64-
* @param feature check for feature to support
65-
* @return true on supported, otherwise false
66+
* @param key key for value to be fetched
67+
* @return property value for the given key. Value type is defined in enum CellularProperty
6668
*/
67-
static const SupportedFeature *_unsupported_features;
68-
static bool is_supported(SupportedFeature feature);
69+
static intptr_t get_property(CellularProperty key);
6970
};
7071

7172
} // namespace mbed

features/cellular/framework/AT/AT_CellularContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ nsapi_error_t AT_CellularContext::do_user_authentication()
289289
{
290290
// if user has defined user name and password we need to call CGAUTH before activating or modifying context
291291
if (_pwd && _uname) {
292-
if (!is_supported(AT_CGAUTH)) {
292+
if (!get_property(AT_CGAUTH)) {
293293
return NSAPI_ERROR_UNSUPPORTED;
294294
}
295295
_at.cmd_start("AT+CGAUTH=");
@@ -572,7 +572,7 @@ void AT_CellularContext::do_connect()
572572
nsapi_error_t AT_CellularContext::open_data_channel()
573573
{
574574
tr_info("CellularContext PPP connect");
575-
if (is_supported(AT_CGDATA)) {
575+
if (get_property(AT_CGDATA)) {
576576
_at.cmd_start("AT+CGDATA=\"PPP\",");
577577
_at.write_int(_cid);
578578
} else {

features/cellular/framework/AT/AT_CellularInformation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ nsapi_error_t AT_CellularInformation::get_serial_number(char *buf, size_t buf_si
5454
return get_info("AT+CGSN", buf, buf_size);
5555
}
5656

57-
if (!is_supported(AT_CGSN_WITH_TYPE)) {
57+
if (!get_property(AT_CGSN_WITH_TYPE)) {
5858
return NSAPI_ERROR_UNSUPPORTED;
5959
}
6060

features/cellular/framework/targets/GEMALTO/CINTERION/GEMALTO_CINTERION_Module.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,39 @@
2424
using namespace mbed;
2525

2626
// unsupported features as per ELS61-E2_ATC_V01.000
27-
static const AT_CellularBase::SupportedFeature unsupported_features_els61[] = {
28-
AT_CellularBase::AT_CGSN_WITH_TYPE,
29-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
27+
static const intptr_t cellular_properties_els61[AT_CellularBase::CELLULAR_PROPERTY_MAX] = {
28+
0, // AT_CGSN_WITH_TYPE
29+
1, // AT_CGDATA
30+
1 // AT_CGAUTH
3031
};
3132

3233
// unsupported features as per BGS2-W_ATC_V00.100
33-
static const AT_CellularBase::SupportedFeature unsupported_features_bgs2[] = {
34-
AT_CellularBase::AT_CGSN_WITH_TYPE,
35-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
36-
};
37-
38-
// unsupported features as per EMS31-US_ATC_V4.9.5
39-
static const AT_CellularBase::SupportedFeature unsupported_features_ems31[] = {
40-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
34+
static const intptr_t cellular_properties_bgs2[AT_CellularBase::CELLULAR_PROPERTY_MAX] = {
35+
0, // AT_CGSN_WITH_TYPE
36+
1, // AT_CGDATA
37+
1 // AT_CGAUTH
4138
};
4239

4340
GEMALTO_CINTERION_Module::Model GEMALTO_CINTERION_Module::_model;
4441

4542
nsapi_error_t GEMALTO_CINTERION_Module::detect_model(const char *model)
4643
{
47-
static const AT_CellularBase::SupportedFeature *unsupported_features;
44+
static const intptr_t *cellular_properties;
4845
if (memcmp(model, "ELS61", sizeof("ELS61") - 1) == 0) {
4946
_model = ModelELS61;
50-
unsupported_features = unsupported_features_els61;
47+
cellular_properties = cellular_properties_els61;
5148
} else if (memcmp(model, "BGS2", sizeof("BGS2") - 1) == 0) {
5249
_model = ModelBGS2;
53-
unsupported_features = unsupported_features_bgs2;
50+
cellular_properties = cellular_properties_bgs2;
5451
} else if (memcmp(model, "EMS31", sizeof("EMS31") - 1) == 0) {
5552
_model = ModelEMS31;
56-
unsupported_features = unsupported_features_ems31;
53+
cellular_properties = NULL;
5754
} else {
5855
tr_error("Cinterion model unsupported %s", model);
5956
return NSAPI_ERROR_UNSUPPORTED;
6057
}
6158
tr_info("Cinterion model %s (%d)", model, _model);
62-
AT_CellularBase::set_unsupported_features(unsupported_features);
59+
AT_CellularBase::set_cellular_properties(cellular_properties);
6360
return NSAPI_ERROR_OK;
6461
}
6562

features/cellular/framework/targets/MultiTech/DragonflyNano/PPP/SARA4_PPP.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
using namespace mbed;
2424
using namespace events;
2525

26-
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
27-
AT_CellularBase::AT_CGSN_WITH_TYPE,
28-
AT_CellularBase::AT_CGDATA,
29-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
26+
static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = {
27+
0, // AT_CGSN_WITH_TYPE
28+
0, // AT_CGDATA
29+
1 // AT_CGAUTH
3030
};
3131

3232
SARA4_PPP::SARA4_PPP(FileHandle *fh) : AT_CellularDevice(fh)
3333
{
34-
AT_CellularBase::set_unsupported_features(unsupported_features);
34+
AT_CellularBase::set_cellular_properties(cellular_properties);
3535
}
3636

3737
SARA4_PPP::~SARA4_PPP()

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@
2929
using namespace events;
3030
using namespace mbed;
3131

32-
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
33-
AT_CellularBase::AT_CGAUTH, // BC95_AT_Commands_Manual_V1.9
34-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
32+
static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = {
33+
1, // AT_CGSN_WITH_TYPE
34+
1, // AT_CGDATA
35+
0 // AT_CGAUTH, BC95_AT_Commands_Manual_V1.9
3536
};
3637

3738
QUECTEL_BC95::QUECTEL_BC95(FileHandle *fh) : AT_CellularDevice(fh)
3839
{
39-
AT_CellularBase::set_unsupported_features(unsupported_features);
40+
AT_CellularBase::set_cellular_properties(cellular_properties);
4041
}
4142

4243
QUECTEL_BC95::~QUECTEL_BC95()

features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ using namespace events;
3131

3232
#define DEVICE_READY_URC "CPIN:"
3333

34-
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
35-
AT_CellularBase::AT_CGSN_WITH_TYPE,
36-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
34+
static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = {
35+
0, // AT_CGSN_WITH_TYPE
36+
1, // AT_CGDATA
37+
1 // AT_CGAUTH, BC95_AT_Commands_Manual_V1.9
3738
};
3839

3940
QUECTEL_BG96::QUECTEL_BG96(FileHandle *fh) : AT_CellularDevice(fh)
4041
{
41-
AT_CellularBase::set_unsupported_features(unsupported_features);
42+
AT_CellularBase::set_cellular_properties(cellular_properties);
4243
}
4344

4445
QUECTEL_BG96::~QUECTEL_BG96()

features/cellular/framework/targets/TELIT/HE910/TELIT_HE910.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
using namespace mbed;
2424
using namespace events;
2525

26-
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
27-
AT_CellularBase::AT_CGSN_WITH_TYPE, // HE910/UE910/UL865/UE866 AT Commands Reference Guide Rev. 11-2006-10-14
28-
AT_CellularBase::AT_CGAUTH, // HE910/UE910/UL865/UE866 AT Commands Reference Guide Rev. 11-2006-10-14
29-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
26+
static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = {
27+
0, // AT_CGSN_WITH_TYPE
28+
1, // AT_CGDATA
29+
0 // AT_CGAUTH
3030
};
3131

3232
TELIT_HE910::TELIT_HE910(FileHandle *fh) : AT_CellularDevice(fh)
3333
{
34-
AT_CellularBase::set_unsupported_features(unsupported_features);
34+
AT_CellularBase::set_cellular_properties(cellular_properties);
3535
}
3636

3737
TELIT_HE910::~TELIT_HE910()

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@ using namespace mbed;
2424
using namespace events;
2525

2626
#ifdef TARGET_UBLOX_C030_R410M
27-
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
28-
AT_CellularBase::AT_CGSN_WITH_TYPE,
29-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
27+
static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = {
28+
0, // AT_CGSN_WITH_TYPE
29+
1, // AT_CGDATA
30+
1 // AT_CGAUTH, BC95_AT_Commands_Manual_V1.9
3031
};
3132
#endif
3233

3334
UBLOX_AT::UBLOX_AT(FileHandle *fh) : AT_CellularDevice(fh)
3435
{
3536
#ifdef TARGET_UBLOX_C030_R410M
36-
AT_CellularBase::set_unsupported_features(unsupported_features);
37+
AT_CellularBase::set_cellular_properties(cellular_properties);
3738
#endif
3839
}
3940

features/cellular/framework/targets/UBLOX/PPP/UBLOX_PPP.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@ using namespace mbed;
2424
using namespace events;
2525

2626
#ifdef TARGET_UBLOX_C027
27-
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
28-
AT_CellularBase::AT_CGSN_WITH_TYPE,
29-
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
27+
static const intptr_t cellular_properties[AT_CellularBase::CELLULAR_PROPERTY_MAX] = {
28+
0, // AT_CGSN_WITH_TYPE
29+
1, // AT_CGDATA
30+
1 // AT_CGAUTH, BC95_AT_Commands_Manual_V1.9
3031
};
3132
#endif
3233

3334
UBLOX_PPP::UBLOX_PPP(FileHandle *fh) : AT_CellularDevice(fh)
3435
{
3536
#ifdef TARGET_UBLOX_C027
36-
AT_CellularBase::set_unsupported_features(unsupported_features);
37+
AT_CellularBase::set_cellular_properties(cellular_properties);
3738
#endif
3839
}
3940

0 commit comments

Comments
 (0)