Skip to content
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

UBLOX cellular api's for UDP and TCP #7619

Merged
merged 5 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions features/cellular/framework/AT/AT_CellularStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class AT_CellularStack : public NetworkStack, public AT_CellularBase
bool started; // socket has been opened on modem stack
bool tx_ready; // socket is ready for sending on modem stack
bool rx_avail; // socket has data for reading on modem stack
volatile nsapi_size_t pending_bytes; // The number of received bytes pending

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably use rx_avail flag here just to indicate that some data is available because you always read how much data really is available when recveiving? If not then you could change type of rx_avail and use it instead of new pending_bytes variable.

There is no need to use volatile here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If rx_avail is unused and nobody else is using it then we can change its type and use it as well.

};

/**
Expand Down
4 changes: 4 additions & 0 deletions features/cellular/framework/common/CellularTargets.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ namespace mbed {
#elif TARGET_MTB_MTS_DRAGONFLY
#define CELLULAR_DEVICE TELIT_HE910
#elif TARGET_UBLOX_C030
#ifdef TARGET_UBLOX_C030_N211
#define CELLULAR_DEVICE UBLOX_AT
#else
#define CELLULAR_DEVICE UBLOX_PPP
#endif
#elif TARGET_UBLOX_C027
#define CELLULAR_DEVICE UBLOX_PPP
#else
Expand Down
59 changes: 59 additions & 0 deletions features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2017, Arm Limited and affiliates.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Years are passing so fast, it's already 2018 :) See also the other files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

* 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 "UBLOX_AT.h"
#include "UBLOX_AT_CellularNetwork.h"
#include "UBLOX_AT_CellularPower.h"

using namespace mbed;
using namespace events;

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

UBLOX_AT::~UBLOX_AT()
{
}

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

CellularPower *UBLOX_AT::open_power(FileHandle *fh)
{
if (!_power) {
ATHandler *atHandler = get_at_handler(fh);
if (atHandler) {
_power = new UBLOX_AT_CellularPower(*atHandler);
if (!_power) {
release_at_handler(atHandler);
}
}
}
return _power;
}
42 changes: 42 additions & 0 deletions features/cellular/framework/targets/UBLOX/AT/UBLOX_AT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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 UBLOX_AT_H_
#define UBLOX_AT_H_

#include "AT_CellularDevice.h"

namespace mbed {

class UBLOX_AT : public AT_CellularDevice
{

public:
UBLOX_AT(events::EventQueue &queue);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run astyle.exe -n --options=.astylerc <file> for coding guidelines.

Copy link
Contributor Author

@mudassar-ublox mudassar-ublox Jul 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated all files.

virtual ~UBLOX_AT();

public: // CellularDevice
virtual CellularNetwork *open_network(FileHandle *fh);
virtual CellularPower *open_power(FileHandle *fh);

public: // NetworkInterface
void handle_urc(FileHandle *fh);
};

} // namespace mbed

#endif // UBLOX_AT_H_
Loading