Skip to content

Commit 70439dd

Browse files
authored
Merge pull request #7677 from AriParkkila/cell-gemalto
Cellular: Gemalto Cinterion support for ELS61 and BGS2
2 parents bd3be2b + 90fe9de commit 70439dd

9 files changed

+957
-3
lines changed

features/cellular/framework/AT/AT_CellularStack.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ nsapi_size_or_error_t AT_CellularStack::socket_sendto(nsapi_socket_t handle, con
276276

277277
ret_val = socket_sendto_impl(socket, addr, data, size);
278278

279-
if (ret_val <= 0) {
280-
tr_error("Error sending to: %s error code: %d", addr.get_ip_address(), ret_val);
281-
} else {
279+
if (ret_val > 0) {
282280
tr_info("Success sending %d Bytes to: %s", ret_val, addr.get_ip_address());
281+
} else if (ret_val != NSAPI_ERROR_WOULD_BLOCK) {
282+
tr_error("Error sending to: %s error code: %d", addr.get_ip_address(), ret_val);
283283
}
284284

285285
_at.unlock();
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (c) 2018, 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 "GEMALTO_CINTERION_CellularNetwork.h"
19+
#include "GEMALTO_CINTERION_Module.h"
20+
#include "AT_CellularInformation.h"
21+
#include "GEMALTO_CINTERION.h"
22+
#include "CellularLog.h"
23+
24+
using namespace mbed;
25+
using namespace events;
26+
27+
GEMALTO_CINTERION::GEMALTO_CINTERION(EventQueue &queue) : AT_CellularDevice(queue)
28+
{
29+
}
30+
31+
GEMALTO_CINTERION::~GEMALTO_CINTERION()
32+
{
33+
}
34+
35+
CellularNetwork *GEMALTO_CINTERION::open_network(FileHandle *fh)
36+
{
37+
if (!_network) {
38+
ATHandler *atHandler = get_at_handler(fh);
39+
if (atHandler) {
40+
_network = new GEMALTO_CINTERION_CellularNetwork(*get_at_handler(fh));
41+
if (!_network) {
42+
release_at_handler(atHandler);
43+
}
44+
}
45+
}
46+
return _network;
47+
}
48+
49+
nsapi_error_t GEMALTO_CINTERION::init_module(FileHandle *fh)
50+
{
51+
CellularInformation *information = open_information(fh);
52+
if (!information) {
53+
return NSAPI_ERROR_NO_MEMORY;
54+
}
55+
char model[sizeof("ELS61") + 1]; // sizeof need to be long enough to hold just the model text
56+
nsapi_error_t ret = information->get_model(model, sizeof(model));
57+
close_information();
58+
if (ret != NSAPI_ERROR_OK) {
59+
tr_error("Cellular model not found!");
60+
return NSAPI_ERROR_DEVICE_ERROR;
61+
}
62+
return GEMALTO_CINTERION_Module::detect_model(model);
63+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2018, 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 GEMALTO_CINTERION_H_
19+
#define GEMALTO_CINTERION_H_
20+
21+
#include "AT_CellularDevice.h"
22+
23+
namespace mbed {
24+
25+
class GEMALTO_CINTERION : public AT_CellularDevice {
26+
public:
27+
28+
GEMALTO_CINTERION(events::EventQueue &queue);
29+
virtual ~GEMALTO_CINTERION();
30+
31+
public: // CellularDevice
32+
virtual CellularNetwork *open_network(FileHandle *fh);
33+
virtual nsapi_error_t init_module(FileHandle *fh);
34+
};
35+
36+
} // namespace mbed
37+
38+
#endif // GEMALTO_CINTERION_H_
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2018, 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 "GEMALTO_CINTERION_CellularNetwork.h"
19+
#include "GEMALTO_CINTERION_CellularStack.h"
20+
#include "GEMALTO_CINTERION_Module.h"
21+
22+
using namespace mbed;
23+
24+
GEMALTO_CINTERION_CellularNetwork::GEMALTO_CINTERION_CellularNetwork(ATHandler &atHandler) : AT_CellularNetwork(atHandler)
25+
{
26+
}
27+
28+
GEMALTO_CINTERION_CellularNetwork::~GEMALTO_CINTERION_CellularNetwork()
29+
{
30+
}
31+
32+
#if !NSAPI_PPP_AVAILABLE
33+
NetworkStack *GEMALTO_CINTERION_CellularNetwork::get_stack()
34+
{
35+
if (!_stack) {
36+
_stack = new GEMALTO_CINTERION_CellularStack(_at, _apn, _cid, _ip_stack_type);
37+
}
38+
return _stack;
39+
}
40+
#endif // NSAPI_PPP_AVAILABLE
41+
42+
bool GEMALTO_CINTERION_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t requested_stack)
43+
{
44+
#if NSAPI_PPP_AVAILABLE
45+
return (requested_stack == IPV4_STACK || requested_stack == IPV6_STACK);
46+
#else
47+
if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelBGS2) {
48+
return (requested_stack == IPV4_STACK);
49+
}
50+
return (requested_stack == IPV4_STACK || requested_stack == IPV6_STACK);
51+
#endif
52+
}
53+
54+
AT_CellularNetwork::RegistrationMode GEMALTO_CINTERION_CellularNetwork::has_registration(RegistrationType reg_type)
55+
{
56+
if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelEMS31) {
57+
return (reg_type == C_EREG) ? RegistrationModeLAC : RegistrationModeDisable;
58+
}
59+
if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelBGS2) {
60+
if (reg_type == C_GREG) {
61+
return RegistrationModeEnable;
62+
}
63+
return (reg_type == C_REG) ? RegistrationModeLAC : RegistrationModeDisable;
64+
}
65+
return (reg_type == C_REG || reg_type == C_GREG || reg_type == C_EREG) ? RegistrationModeLAC : RegistrationModeDisable;
66+
}
67+
68+
nsapi_error_t GEMALTO_CINTERION_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opsAct)
69+
{
70+
_op_act = RAT_UNKNOWN;
71+
return NSAPI_ERROR_UNSUPPORTED;
72+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2018, 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 GEMALTO_CINTERION_CELLULAR_NETWORK_H_
19+
#define GEMALTO_CINTERION_CELLULAR_NETWORK_H_
20+
21+
#include "AT_CellularNetwork.h"
22+
23+
namespace mbed {
24+
25+
class GEMALTO_CINTERION_CellularNetwork : public AT_CellularNetwork {
26+
public:
27+
GEMALTO_CINTERION_CellularNetwork(ATHandler &atHandler);
28+
virtual ~GEMALTO_CINTERION_CellularNetwork();
29+
30+
protected:
31+
#if !NSAPI_PPP_AVAILABLE
32+
virtual NetworkStack *get_stack();
33+
#endif // NSAPI_PPP_AVAILABLE
34+
35+
virtual RegistrationMode has_registration(RegistrationType reg_type);
36+
37+
virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack);
38+
39+
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology opsAct);
40+
};
41+
42+
} // namespace mbed
43+
44+
#endif // GEMALTO_CINTERION_CELLULAR_NETWORK_H_

0 commit comments

Comments
 (0)