-
Notifications
You must be signed in to change notification settings - Fork 3k
[Wio 3G] Adding platform #7098
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
[Wio 3G] Adding platform #7098
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
features/cellular/framework/targets/QUECTEL/UG96/QUECTEL_UG96.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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 "QUECTEL/UG96/QUECTEL_UG96.h" | ||
#include "QUECTEL/UG96/QUECTEL_UG96_CellularNetwork.h" | ||
#include "QUECTEL/UG96/QUECTEL_UG96_CellularPower.h" | ||
|
||
using namespace mbed; | ||
using namespace events; | ||
|
||
#define CONNECT_DELIM "\r\n" | ||
#define CONNECT_BUFFER_SIZE (1280 + 80 + 80) // AT response + sscanf format | ||
#define CONNECT_TIMEOUT 8000 | ||
|
||
#define MAX_STARTUP_TRIALS 5 | ||
#define MAX_RESET_TRIALS 5 | ||
|
||
QUECTEL_UG96::QUECTEL_UG96(EventQueue &queue) : AT_CellularDevice(queue) | ||
{ | ||
} | ||
|
||
QUECTEL_UG96::~QUECTEL_UG96() | ||
{ | ||
} | ||
|
||
CellularNetwork *QUECTEL_UG96::open_network(FileHandle *fh) | ||
{ | ||
if (!_network) { | ||
_network = new QUECTEL_UG96_CellularNetwork(*get_at_handler(fh)); | ||
} | ||
return _network; | ||
} | ||
|
||
CellularPower *QUECTEL_UG96::open_power(FileHandle *fh) | ||
{ | ||
if (!_power) { | ||
ATHandler *atHandler = get_at_handler(fh); | ||
if (atHandler) { | ||
_power = new QUECTEL_UG96_CellularPower(*atHandler); | ||
if (!_power) { | ||
release_at_handler(atHandler); | ||
} | ||
} | ||
} | ||
return _power; | ||
} |
50 changes: 50 additions & 0 deletions
50
features/cellular/framework/targets/QUECTEL/UG96/QUECTEL_UG96.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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 QUECTEL_UG96_H_ | ||
#define QUECTEL_UG96_H_ | ||
|
||
#include "AT_CellularDevice.h" | ||
|
||
namespace mbed { | ||
|
||
#ifdef TARGET_WIO_3G | ||
#define CELLULAR_SERIAL_TX PA_2 | ||
#define CELLULAR_SERIAL_RX PA_3 | ||
#else | ||
#define CELLULAR_SERIAL_TX PC_1 | ||
#define CELLULAR_SERIAL_RX PC_0 | ||
#endif | ||
|
||
class QUECTEL_UG96 : public AT_CellularDevice | ||
{ | ||
public: | ||
|
||
QUECTEL_UG96(events::EventQueue &queue); | ||
virtual ~QUECTEL_UG96(); | ||
|
||
public: // CellularDevice | ||
virtual CellularNetwork *open_network(FileHandle *fh); | ||
virtual CellularPower *open_power(FileHandle *fh); | ||
|
||
public: // NetworkInterface | ||
void handle_urc(FileHandle *fh); | ||
|
||
}; | ||
|
||
} // namespace mbed | ||
#endif // QUECTEL_UG96_H_ |
65 changes: 65 additions & 0 deletions
65
features/cellular/framework/targets/QUECTEL/UG96/QUECTEL_UG96_CellularNetwork.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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 "QUECTEL/UG96/QUECTEL_UG96_CellularNetwork.h" | ||
|
||
using namespace mbed; | ||
|
||
QUECTEL_UG96_CellularNetwork::QUECTEL_UG96_CellularNetwork(ATHandler &atHandler) : AT_CellularNetwork(atHandler) | ||
{ | ||
} | ||
|
||
QUECTEL_UG96_CellularNetwork::~QUECTEL_UG96_CellularNetwork() | ||
{ | ||
} | ||
|
||
bool QUECTEL_UG96_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t requested_stack) | ||
{ | ||
return requested_stack == IPV4_STACK ? true : false; | ||
} | ||
|
||
bool QUECTEL_UG96_CellularNetwork::has_registration(RegistrationType reg_type) | ||
{ | ||
return (reg_type == C_REG || reg_type == C_GREG); | ||
} | ||
|
||
nsapi_error_t QUECTEL_UG96_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opRat) | ||
{ | ||
_op_act = RAT_UNKNOWN; | ||
return NSAPI_ERROR_UNSUPPORTED; | ||
} | ||
|
||
nsapi_error_t QUECTEL_UG96_CellularNetwork::do_user_authentication() | ||
{ | ||
if (_pwd && _uname) { | ||
_at.cmd_start("AT+QICSGP="); | ||
_at.write_int(_cid); | ||
_at.write_int(1); // context type 1=IPv4 | ||
_at.write_string(_apn); | ||
_at.write_string(_uname); | ||
_at.write_string(_pwd); | ||
_at.write_int(_authentication_type); | ||
_at.cmd_stop(); | ||
_at.resp_start(); | ||
_at.resp_stop(); | ||
if (_at.get_last_error() != NSAPI_ERROR_OK) { | ||
return NSAPI_ERROR_AUTH_FAILURE; | ||
} | ||
} | ||
|
||
return NSAPI_ERROR_OK; | ||
} |
43 changes: 43 additions & 0 deletions
43
features/cellular/framework/targets/QUECTEL/UG96/QUECTEL_UG96_CellularNetwork.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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 QUECTEL_UG96_CELLULAR_NETWORK_H_ | ||
#define QUECTEL_UG96_CELLULAR_NETWORK_H_ | ||
|
||
#include "AT_CellularNetwork.h" | ||
|
||
namespace mbed { | ||
|
||
class QUECTEL_UG96_CellularNetwork : public AT_CellularNetwork | ||
{ | ||
public: | ||
QUECTEL_UG96_CellularNetwork(ATHandler &atHandler); | ||
virtual ~QUECTEL_UG96_CellularNetwork(); | ||
|
||
protected: | ||
virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack); | ||
|
||
virtual bool has_registration(RegistrationType rat); | ||
|
||
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology opRat); | ||
|
||
virtual nsapi_error_t do_user_authentication(); | ||
}; | ||
|
||
} // namespace mbed | ||
|
||
#endif // QUECTEL_UG96_CELLULAR_NETWORK_H_ |
49 changes: 49 additions & 0 deletions
49
features/cellular/framework/targets/QUECTEL/UG96/QUECTEL_UG96_CellularPower.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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 "QUECTEL_UG96_CellularPower.h" | ||
|
||
#include "onboard_modem_api.h" | ||
|
||
using namespace mbed; | ||
|
||
QUECTEL_UG96_CellularPower::QUECTEL_UG96_CellularPower(ATHandler &atHandler) : AT_CellularPower(atHandler) | ||
{ | ||
|
||
} | ||
|
||
QUECTEL_UG96_CellularPower::~QUECTEL_UG96_CellularPower() | ||
{ | ||
|
||
} | ||
|
||
nsapi_error_t QUECTEL_UG96_CellularPower::on() | ||
{ | ||
#if MODEM_ON_BOARD | ||
::onboard_modem_init(); | ||
::onboard_modem_power_up(); | ||
#endif | ||
return NSAPI_ERROR_OK; | ||
} | ||
|
||
nsapi_error_t QUECTEL_UG96_CellularPower::off() | ||
{ | ||
#if MODEM_ON_BOARD | ||
::onboard_modem_power_down(); | ||
#endif | ||
return NSAPI_ERROR_OK; | ||
} |
40 changes: 40 additions & 0 deletions
40
features/cellular/framework/targets/QUECTEL/UG96/QUECTEL_UG96_CellularPower.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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 QUECTEL_UG96_CELLULARPOWER_H_ | ||
#define QUECTEL_UG96_CELLULARPOWER_H_ | ||
|
||
#include "AT_CellularPower.h" | ||
|
||
namespace mbed { | ||
|
||
class QUECTEL_UG96_CellularPower : public AT_CellularPower | ||
{ | ||
public: | ||
QUECTEL_UG96_CellularPower(ATHandler &atHandler); | ||
virtual ~QUECTEL_UG96_CellularPower(); | ||
|
||
public: //from CellularPower | ||
|
||
virtual nsapi_error_t on(); | ||
|
||
virtual nsapi_error_t off(); | ||
}; | ||
|
||
} // namespace mbed | ||
|
||
#endif // QUECTEL_UG96_CELLULARPOWER_H_ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for error value anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean no error return value? What about NSAPI_ERROR_AUTH_FAILURE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this topic is not about adding target, so I didn’t make any change about this. Please avoid this topic in this PR.