File tree Expand file tree Collapse file tree 4 files changed +116
-2
lines changed
features/cellular/framework/targets/QUECTEL/BC95 Expand file tree Collapse file tree 4 files changed +116
-2
lines changed Original file line number Diff line number Diff line change 17
17
18
18
#include " QUECTEL_BC95_CellularNetwork.h"
19
19
#include " QUECTEL_BC95_CellularPower.h"
20
+ #include " QUECTEL_BC95_CellularSIM.h"
20
21
21
22
#include " QUECTEL_BC95.h"
22
23
@@ -41,15 +42,41 @@ QUECTEL_BC95::~QUECTEL_BC95()
41
42
CellularNetwork *QUECTEL_BC95::open_network (FileHandle *fh)
42
43
{
43
44
if (!_network) {
44
- _network = new QUECTEL_BC95_CellularNetwork (*get_at_handler (fh));
45
+ ATHandler *atHandler = get_at_handler (fh);
46
+ if (atHandler) {
47
+ _network = new QUECTEL_BC95_CellularNetwork (*atHandler);
48
+ if (!_network) {
49
+ release_at_handler (atHandler);
50
+ }
51
+ }
45
52
}
46
53
return _network;
47
54
}
48
55
49
56
CellularPower *QUECTEL_BC95::open_power (FileHandle *fh)
50
57
{
51
58
if (!_power) {
52
- _power = new QUECTEL_BC95_CellularPower (*get_at_handler (fh));
59
+ ATHandler *atHandler = get_at_handler (fh);
60
+ if (atHandler) {
61
+ _power = new QUECTEL_BC95_CellularPower (*atHandler);
62
+ if (!_power) {
63
+ release_at_handler (atHandler);
64
+ }
65
+ }
53
66
}
54
67
return _power;
55
68
}
69
+
70
+ CellularSIM *QUECTEL_BC95::open_sim (FileHandle *fh)
71
+ {
72
+ if (!_sim) {
73
+ ATHandler *atHandler = get_at_handler (fh);
74
+ if (atHandler) {
75
+ _sim = new QUECTEL_BC95_CellularSIM (*atHandler);
76
+ if (!_sim) {
77
+ release_at_handler (atHandler);
78
+ }
79
+ }
80
+ }
81
+ return _sim;
82
+ }
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ class QUECTEL_BC95 : public AT_CellularDevice
32
32
public: // CellularDevice
33
33
virtual CellularNetwork *open_network (FileHandle *fh);
34
34
virtual CellularPower *open_power (FileHandle *fh);
35
+ virtual CellularSIM *open_sim (FileHandle *fh);
35
36
36
37
public: // NetworkInterface
37
38
void handle_urc (FileHandle *fh);
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2017, Arm Limited and affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #include " QUECTEL_BC95_CellularSIM.h"
19
+ #include " CellularLog.h"
20
+
21
+ using namespace mbed ;
22
+
23
+ QUECTEL_BC95_CellularSIM::QUECTEL_BC95_CellularSIM (ATHandler &atHandler) : AT_CellularSIM(atHandler)
24
+ {
25
+
26
+ }
27
+
28
+ QUECTEL_BC95_CellularSIM::~QUECTEL_BC95_CellularSIM ()
29
+ {
30
+
31
+ }
32
+
33
+ nsapi_error_t QUECTEL_BC95_CellularSIM::get_sim_state (SimState &state)
34
+ {
35
+ _at.lock ();
36
+ _at.flush ();
37
+ _at.cmd_start (" AT+NCCID?" );
38
+ _at.cmd_stop ();
39
+ _at.resp_start (" +NCCID:" );
40
+ if (_at.info_resp ()) {
41
+ state = SimStateReady;
42
+ } else {
43
+ tr_warn (" SIM not readable." );
44
+ state = SimStateUnknown; // SIM may not be ready yet
45
+ }
46
+ _at.resp_stop ();
47
+ return _at.unlock_return_error ();
48
+ }
49
+
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2017, Arm Limited and affiliates.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #ifndef QUECTEL_BC95_CELLULAR_SIM_H_
19
+ #define QUECTEL_BC95_CELLULAR_SIM_H_
20
+
21
+ #include " AT_CellularSIM.h"
22
+
23
+ namespace mbed {
24
+
25
+ class QUECTEL_BC95_CellularSIM : public AT_CellularSIM
26
+ {
27
+ public:
28
+ QUECTEL_BC95_CellularSIM (ATHandler &atHandler);
29
+ virtual ~QUECTEL_BC95_CellularSIM ();
30
+
31
+ public: // from CellularSIM
32
+ virtual nsapi_error_t get_sim_state (SimState &state);
33
+ };
34
+
35
+ } // namespace mbed
36
+
37
+ #endif // QUECTEL_BC95_CELLULAR_SIM_H_
You can’t perform that action at this time.
0 commit comments