mirror of https://github.com/ARMmbed/mbed-os.git
Own SIM state retrieval for Quectel BC95
parent
95ca5de41d
commit
5cb29a7ea4
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "QUECTEL_BC95_CellularNetwork.h"
|
||||
#include "QUECTEL_BC95_CellularPower.h"
|
||||
#include "QUECTEL_BC95_CellularSIM.h"
|
||||
|
||||
#include "QUECTEL_BC95.h"
|
||||
|
||||
|
@ -41,7 +42,13 @@ QUECTEL_BC95::~QUECTEL_BC95()
|
|||
CellularNetwork *QUECTEL_BC95::open_network(FileHandle *fh)
|
||||
{
|
||||
if (!_network) {
|
||||
_network = new QUECTEL_BC95_CellularNetwork(*get_at_handler(fh));
|
||||
ATHandler *atHandler = get_at_handler(fh);
|
||||
if (atHandler) {
|
||||
_network = new QUECTEL_BC95_CellularNetwork(*atHandler);
|
||||
if (!_network) {
|
||||
release_at_handler(atHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
return _network;
|
||||
}
|
||||
|
@ -49,7 +56,27 @@ CellularNetwork *QUECTEL_BC95::open_network(FileHandle *fh)
|
|||
CellularPower *QUECTEL_BC95::open_power(FileHandle *fh)
|
||||
{
|
||||
if (!_power) {
|
||||
_power = new QUECTEL_BC95_CellularPower(*get_at_handler(fh));
|
||||
ATHandler *atHandler = get_at_handler(fh);
|
||||
if (atHandler) {
|
||||
_power = new QUECTEL_BC95_CellularPower(*atHandler);
|
||||
if (!_power) {
|
||||
release_at_handler(atHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
return _power;
|
||||
}
|
||||
|
||||
CellularSIM *QUECTEL_BC95::open_sim(FileHandle *fh)
|
||||
{
|
||||
if (!_sim) {
|
||||
ATHandler *atHandler = get_at_handler(fh);
|
||||
if (atHandler) {
|
||||
_sim = new QUECTEL_BC95_CellularSIM(*atHandler);
|
||||
if (!_sim) {
|
||||
release_at_handler(atHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
return _sim;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
public: // CellularDevice
|
||||
virtual CellularNetwork *open_network(FileHandle *fh);
|
||||
virtual CellularPower *open_power(FileHandle *fh);
|
||||
virtual CellularSIM *open_sim(FileHandle *fh);
|
||||
|
||||
public: // NetworkInterface
|
||||
void handle_urc(FileHandle *fh);
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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_BC95_CellularSIM.h"
|
||||
#include "CellularLog.h"
|
||||
|
||||
using namespace mbed;
|
||||
|
||||
QUECTEL_BC95_CellularSIM::QUECTEL_BC95_CellularSIM(ATHandler &atHandler) : AT_CellularSIM(atHandler)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QUECTEL_BC95_CellularSIM::~QUECTEL_BC95_CellularSIM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsapi_error_t QUECTEL_BC95_CellularSIM::get_sim_state(SimState &state)
|
||||
{
|
||||
_at.lock();
|
||||
_at.flush();
|
||||
_at.cmd_start("AT+NCCID?");
|
||||
_at.cmd_stop();
|
||||
_at.resp_start("+NCCID:");
|
||||
if (_at.info_resp()) {
|
||||
state = SimStateReady;
|
||||
} else {
|
||||
tr_warn("SIM not readable.");
|
||||
state = SimStateUnknown; // SIM may not be ready yet
|
||||
}
|
||||
_at.resp_stop();
|
||||
return _at.unlock_return_error();
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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_BC95_CELLULAR_SIM_H_
|
||||
#define QUECTEL_BC95_CELLULAR_SIM_H_
|
||||
|
||||
#include "AT_CellularSIM.h"
|
||||
|
||||
namespace mbed {
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
||||
#endif // QUECTEL_BC95_CELLULAR_SIM_H_
|
Loading…
Reference in New Issue