mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: Target support for AT+CCID and AT+CGSN
parent
44365bccd0
commit
7d006f6f6a
|
@ -70,12 +70,12 @@ public:
|
|||
* @return zero on success, on failure negative error code
|
||||
*/
|
||||
enum SerialNumberType {
|
||||
SN = 0,
|
||||
IMEI = 1,
|
||||
IMEISV = 2,
|
||||
SVN = 3
|
||||
SN = 0, // Serial Number
|
||||
IMEI = 1, // International Mobile station Equipment Identity
|
||||
IMEISV = 2, // IMEI and Software Version number
|
||||
SVN = 3 // Software Version Number
|
||||
};
|
||||
virtual nsapi_size_or_error_t get_serial_number(char *buf, size_t buf_size, SerialNumberType type) = 0;
|
||||
virtual nsapi_size_or_error_t get_serial_number(char *buf, size_t buf_size, SerialNumberType type = SN) = 0;
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -16,15 +16,15 @@
|
|||
*/
|
||||
|
||||
#include "AT_CellularBase.h"
|
||||
#include "CellularLog.h"
|
||||
|
||||
using namespace mbed;
|
||||
|
||||
AT_CellularBase::AT_CellularBase(ATHandler& at) : _at(at)
|
||||
AT_CellularBase::AT_CellularBase(ATHandler &at) : _at(at)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ATHandler& AT_CellularBase::get_at_handler()
|
||||
ATHandler &AT_CellularBase::get_at_handler()
|
||||
{
|
||||
return _at;
|
||||
}
|
||||
|
@ -34,3 +34,25 @@ device_err_t AT_CellularBase::get_device_error() const
|
|||
return _at.get_last_device_error();
|
||||
}
|
||||
|
||||
AT_CellularBase::SupportedFeature const *AT_CellularBase::_unsupported_features;
|
||||
|
||||
void AT_CellularBase::set_unsupported_features(const SupportedFeature *unsupported_features)
|
||||
{
|
||||
_unsupported_features = unsupported_features;
|
||||
}
|
||||
|
||||
bool AT_CellularBase::is_supported(SupportedFeature feature)
|
||||
{
|
||||
if (!_unsupported_features) {
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -26,16 +26,15 @@ namespace mbed {
|
|||
*
|
||||
* A base class for AT-classes.
|
||||
*/
|
||||
class AT_CellularBase
|
||||
{
|
||||
class AT_CellularBase {
|
||||
public:
|
||||
AT_CellularBase(ATHandler& at);
|
||||
AT_CellularBase(ATHandler &at);
|
||||
|
||||
/** Getter for at handler. Common method for all AT-classes.
|
||||
*
|
||||
* @return reference to ATHandler
|
||||
*/
|
||||
ATHandler& get_at_handler();
|
||||
ATHandler &get_at_handler();
|
||||
|
||||
/** Gets the device error that happened when using AT commands/responses. This is at error
|
||||
* returned by the device. Returned CME/CMS errors can be found from 3gpp documents 27007 and 27005.
|
||||
|
@ -44,8 +43,28 @@ 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
|
||||
SUPPORTED_FEATURE_END_MARK // must be last element in the array of features
|
||||
};
|
||||
static void set_unsupported_features(const SupportedFeature *unsupported_features);
|
||||
|
||||
protected:
|
||||
ATHandler& _at;
|
||||
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.
|
||||
*
|
||||
* @param feature check for feature to support
|
||||
* @return true on supported, otherwise false
|
||||
*/
|
||||
static const SupportedFeature *_unsupported_features;
|
||||
static bool is_supported(SupportedFeature feature);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -49,6 +49,11 @@ nsapi_error_t AT_CellularInformation::get_serial_number(char *buf, size_t buf_si
|
|||
if (type == SN) {
|
||||
return get_info("AT+CGSN", buf, buf_size);
|
||||
}
|
||||
|
||||
if (!is_supported(AT_CGSN_WITH_TYPE)) {
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
_at.lock();
|
||||
_at.cmd_start("AT+CGSN=");
|
||||
_at.write_int(type);
|
||||
|
|
|
@ -47,3 +47,14 @@ nsapi_error_t QUECTEL_BC95_CellularSIM::get_sim_state(SimState &state)
|
|||
return _at.unlock_return_error();
|
||||
}
|
||||
|
||||
// According to BC95_AT_Commands_Manual_V1.9
|
||||
nsapi_error_t QUECTEL_BC95_CellularSIM::get_iccid(char *buf, size_t buf_size)
|
||||
{
|
||||
_at.lock();
|
||||
_at.cmd_start("AT+NCCID?");
|
||||
_at.cmd_stop();
|
||||
_at.resp_start("+NCCID:");
|
||||
_at.read_string(buf, buf_size);
|
||||
_at.resp_stop();
|
||||
return _at.unlock_return_error();
|
||||
}
|
||||
|
|
|
@ -22,14 +22,14 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
class QUECTEL_BC95_CellularSIM : public AT_CellularSIM
|
||||
{
|
||||
class QUECTEL_BC95_CellularSIM : public AT_CellularSIM {
|
||||
public:
|
||||
QUECTEL_BC95_CellularSIM(ATHandler &atHandler);
|
||||
virtual ~QUECTEL_BC95_CellularSIM();
|
||||
|
||||
public: //from CellularSIM
|
||||
virtual nsapi_error_t get_sim_state(SimState &state);
|
||||
virtual nsapi_error_t get_iccid(char *buf, size_t buf_size);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -29,8 +29,14 @@ using namespace events;
|
|||
#define MAX_STARTUP_TRIALS 5
|
||||
#define MAX_RESET_TRIALS 5
|
||||
|
||||
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
|
||||
AT_CellularBase::AT_CGSN_WITH_TYPE,
|
||||
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
|
||||
};
|
||||
|
||||
QUECTEL_BG96::QUECTEL_BG96(EventQueue &queue) : AT_CellularDevice(queue)
|
||||
{
|
||||
AT_CellularBase::set_unsupported_features(unsupported_features);
|
||||
}
|
||||
|
||||
QUECTEL_BG96::~QUECTEL_BG96()
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "QUECTEL_BG96_CellularSIM.h"
|
||||
#include "CellularLog.h"
|
||||
|
||||
using namespace mbed;
|
||||
|
||||
QUECTEL_BG96_CellularSIM::QUECTEL_BG96_CellularSIM(ATHandler &atHandler) : AT_CellularSIM(atHandler)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QUECTEL_BG96_CellularSIM::~QUECTEL_BG96_CellularSIM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// According to BG96_AT_Commands_Manual_V2.0
|
||||
nsapi_error_t QUECTEL_BG96_CellularSIM::get_iccid(char *buf, size_t buf_size)
|
||||
{
|
||||
_at.lock();
|
||||
_at.cmd_start("AT+QCCID");
|
||||
_at.cmd_stop();
|
||||
_at.resp_start("+QCCID:");
|
||||
_at.read_string(buf, buf_size);
|
||||
_at.resp_stop();
|
||||
return _at.unlock_return_error();
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef QUECTEL_BG96_CELLULAR_SIM_H_
|
||||
#define QUECTEL_BG96_CELLULAR_SIM_H_
|
||||
|
||||
#include "AT_CellularSIM.h"
|
||||
|
||||
namespace mbed {
|
||||
|
||||
class QUECTEL_BG96_CellularSIM : public AT_CellularSIM {
|
||||
public:
|
||||
QUECTEL_BG96_CellularSIM(ATHandler &atHandler);
|
||||
virtual ~QUECTEL_BG96_CellularSIM();
|
||||
|
||||
public: //from CellularSIM
|
||||
virtual nsapi_error_t get_iccid(char *buf, size_t buf_size);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
||||
#endif // QUECTEL_BG96_CELLULAR_SIM_H_
|
|
@ -22,9 +22,14 @@
|
|||
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::SUPPORTED_FEATURE_END_MARK
|
||||
};
|
||||
|
||||
TELIT_HE910::TELIT_HE910(EventQueue &queue) : AT_CellularDevice(queue)
|
||||
{
|
||||
|
||||
AT_CellularBase::set_unsupported_features(unsupported_features);
|
||||
}
|
||||
|
||||
TELIT_HE910::~TELIT_HE910()
|
||||
|
|
Loading…
Reference in New Issue