Cellular: changed support features to CellularProperty array.

pull/9472/head
Teppo Järvelin 2018-12-05 12:58:30 +02:00 committed by Ari Parkkila
parent c7486b2a0d
commit 8fcd2e0401
14 changed files with 95 additions and 114 deletions

View File

@ -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());
}

View File

@ -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;
}

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
#include "ATHandler.h"
#include "AT_CellularBase.h"
namespace AT_CellularBase_stub {
extern mbed::ATHandler *handler_value;

View File

@ -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];
}

View File

@ -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***<cid>#
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***<cid>#
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

View File

@ -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 {

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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()

View File

@ -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()

View File

@ -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<void()> callback)
{
return _at->set_urc_handler(DEVICE_READY_URC, callback);
}

View File

@ -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()

View File

@ -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
}

View File

@ -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
}