Skip to content

Cellular: Gemalto Cinterion support for ELS61 and BGS2 #7677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions features/cellular/framework/AT/AT_CellularStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ nsapi_size_or_error_t AT_CellularStack::socket_sendto(nsapi_socket_t handle, con

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

if (ret_val <= 0) {
tr_error("Error sending to: %s error code: %d", addr.get_ip_address(), ret_val);
} else {
if (ret_val > 0) {
tr_info("Success sending %d Bytes to: %s", ret_val, addr.get_ip_address());
} else if (ret_val != NSAPI_ERROR_WOULD_BLOCK) {
tr_error("Error sending to: %s error code: %d", addr.get_ip_address(), ret_val);
}

_at.unlock();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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 "GEMALTO_CINTERION_CellularNetwork.h"
#include "GEMALTO_CINTERION_Module.h"
#include "AT_CellularInformation.h"
#include "GEMALTO_CINTERION.h"
#include "CellularLog.h"

using namespace mbed;
using namespace events;

GEMALTO_CINTERION::GEMALTO_CINTERION(EventQueue &queue) : AT_CellularDevice(queue)
{
}

GEMALTO_CINTERION::~GEMALTO_CINTERION()
{
}

CellularNetwork *GEMALTO_CINTERION::open_network(FileHandle *fh)
{
if (!_network) {
ATHandler *atHandler = get_at_handler(fh);
if (atHandler) {
_network = new GEMALTO_CINTERION_CellularNetwork(*get_at_handler(fh));
if (!_network) {
release_at_handler(atHandler);
}
}
}
return _network;
}

nsapi_error_t GEMALTO_CINTERION::init_module(FileHandle *fh)
{
CellularInformation *information = open_information(fh);
if (!information) {
return NSAPI_ERROR_NO_MEMORY;
}
char model[sizeof("ELS61") + 1]; // sizeof need to be long enough to hold just the model text
nsapi_error_t ret = information->get_model(model, sizeof(model));
close_information();
if (ret != NSAPI_ERROR_OK) {
tr_error("Cellular model not found!");
return NSAPI_ERROR_DEVICE_ERROR;
}
return GEMALTO_CINTERION_Module::detect_model(model);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 GEMALTO_CINTERION_H_
#define GEMALTO_CINTERION_H_

#include "AT_CellularDevice.h"

namespace mbed {

class GEMALTO_CINTERION : public AT_CellularDevice {
public:

GEMALTO_CINTERION(events::EventQueue &queue);
virtual ~GEMALTO_CINTERION();

public: // CellularDevice
virtual CellularNetwork *open_network(FileHandle *fh);
virtual nsapi_error_t init_module(FileHandle *fh);
};

} // namespace mbed

#endif // GEMALTO_CINTERION_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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 "GEMALTO_CINTERION_CellularNetwork.h"
#include "GEMALTO_CINTERION_CellularStack.h"
#include "GEMALTO_CINTERION_Module.h"

using namespace mbed;

GEMALTO_CINTERION_CellularNetwork::GEMALTO_CINTERION_CellularNetwork(ATHandler &atHandler) : AT_CellularNetwork(atHandler)
{
}

GEMALTO_CINTERION_CellularNetwork::~GEMALTO_CINTERION_CellularNetwork()
{
}

#if !NSAPI_PPP_AVAILABLE
NetworkStack *GEMALTO_CINTERION_CellularNetwork::get_stack()
{
if (!_stack) {
_stack = new GEMALTO_CINTERION_CellularStack(_at, _apn, _cid, _ip_stack_type);
}
return _stack;
}
#endif // NSAPI_PPP_AVAILABLE

bool GEMALTO_CINTERION_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t requested_stack)
{
#if NSAPI_PPP_AVAILABLE
return (requested_stack == IPV4_STACK || requested_stack == IPV6_STACK);
#else
if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelBGS2) {
return (requested_stack == IPV4_STACK);
}
return (requested_stack == IPV4_STACK || requested_stack == IPV6_STACK);
#endif
}

AT_CellularNetwork::RegistrationMode GEMALTO_CINTERION_CellularNetwork::has_registration(RegistrationType reg_type)
{
if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelEMS31) {
return (reg_type == C_EREG) ? RegistrationModeLAC : RegistrationModeDisable;
}
if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelBGS2) {
if (reg_type == C_GREG) {
return RegistrationModeEnable;
}
return (reg_type == C_REG) ? RegistrationModeLAC : RegistrationModeDisable;
}
return (reg_type == C_REG || reg_type == C_GREG || reg_type == C_EREG) ? RegistrationModeLAC : RegistrationModeDisable;
}

nsapi_error_t GEMALTO_CINTERION_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opsAct)
{
_op_act = RAT_UNKNOWN;
return NSAPI_ERROR_UNSUPPORTED;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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 GEMALTO_CINTERION_CELLULAR_NETWORK_H_
#define GEMALTO_CINTERION_CELLULAR_NETWORK_H_

#include "AT_CellularNetwork.h"

namespace mbed {

class GEMALTO_CINTERION_CellularNetwork : public AT_CellularNetwork {
public:
GEMALTO_CINTERION_CellularNetwork(ATHandler &atHandler);
virtual ~GEMALTO_CINTERION_CellularNetwork();

protected:
#if !NSAPI_PPP_AVAILABLE
virtual NetworkStack *get_stack();
#endif // NSAPI_PPP_AVAILABLE

virtual RegistrationMode has_registration(RegistrationType reg_type);

virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack);

virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology opsAct);
};

} // namespace mbed

#endif // GEMALTO_CINTERION_CELLULAR_NETWORK_H_
Loading